Dont' trivial bitcast between differently sized structs.

Really we want to only cast between equally sized types. SIL does not really
have a concept of types of the same size so this solution is a workaround
(temporary) for acutal code in the standard library which casts a pointer of an
UTF16 type to a pointer of an UTF8 type.

rdar://18118602

Swift SVN r21470
This commit is contained in:
Arnold Schwaighofer
2014-08-27 00:05:04 +00:00
parent 0085b94509
commit ef3adb2186
4 changed files with 64 additions and 0 deletions

View File

@@ -409,6 +409,15 @@ forwardAddressValueToUncheckedAddrToLoad(SILValue Address,
// If the output is trivial, we have a trivial bit cast.
if (OutputIsTrivial) {
// The structs could have different size. We have code in the stdlib that
// casts pointers to differently sized integer types. This code prevents
// that we bitcast the values.
SILType InputTy = UADCI->getOperand().getType();
if (OutputTy.getStructOrBoundGenericStruct() &&
InputTy.getStructOrBoundGenericStruct())
return SILValue();
CastValue = B.createUncheckedTrivialBitCast(UADCI->getLoc(), StoredValue,
OutputTy.getObjectType());
} else {