mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Rely on the stdlib's runtime assert and undefined behavior to promote 3/4 remaining unchecked_addr_cast types to object bit casts.
This commit enables support in the optimizer for promoting the following unchecked_addr_cast kinds to object bit casts: 1. (Trivial => Trivial) yields a trivial bit cast. 2. (Non-Trivial => Trivial) yields a trivial bit cast. 3. (Non-Trivial => Non-Trivial) yields a ref bit cast. We do not promote conversions in between trivial and non-trivial types since a trivial bit cast must have a trivial output and if we allowed for ref bit casts in between the two, we would be breaking the rule that ref bit casts do not change the reference semantics of its input, output types. Technically, we could lower trivial => trivial as a ref cast and then simplify later but that is unnecessary currently. <rdar://problem/17373087> Swift SVN r19784
This commit is contained in:
@@ -262,11 +262,6 @@ tryToForwardAddressValueToUncheckedAddrToLoad(SILValue Address,
|
||||
SILType InputTy = UADCI->getOperand().getType();
|
||||
SILType OutputTy = UADCI->getType();
|
||||
|
||||
// If OutputTy is not layout compatible with InputTy, there is nothing we can
|
||||
// do here.
|
||||
if(!OutputTy.isLayoutCompatibleWith(InputTy, Mod))
|
||||
return SILValue();
|
||||
|
||||
bool InputIsTrivial = InputTy.isTrivial(Mod);
|
||||
bool OutputIsTrivial = OutputTy.isTrivial(Mod);
|
||||
|
||||
@@ -274,11 +269,16 @@ tryToForwardAddressValueToUncheckedAddrToLoad(SILValue Address,
|
||||
if (InputTy.hasArchetype() || OutputTy.hasArchetype())
|
||||
return SILValue();
|
||||
|
||||
// If we have a trivial input and a non-trivial output bail.
|
||||
if (InputIsTrivial && !OutputIsTrivial) {
|
||||
return SILValue();
|
||||
}
|
||||
|
||||
SILBuilder B(LI);
|
||||
SILValue CastValue;
|
||||
|
||||
// If the output is trivial, we have a trivial bit cast.
|
||||
if (InputIsTrivial || OutputIsTrivial) {
|
||||
if (OutputIsTrivial) {
|
||||
CastValue = B.createUncheckedTrivialBitCast(UADCI->getLoc(), StoredValue,
|
||||
OutputTy.getObjectType());
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user