mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Safely implement strict TBAA rules.
This fixes type punning issues with unsafeBitCast. The optimizer is still too aggressive with UnsafePointer. To fix that, we first need an explicit API for circumventing type safety (rdar://23406272). I should be able to fix the following regressions by migrating the stdlib away from unsafeBitCast to unsafeReferenceCast (~2 weeks). Slowdowns: |.Benchmark.................|..Before.|...After.|.Speedup| |.ArrayInClass..............|...49.00.|...78.00.|.-37.2%.| |.Sim2DArray................|..471.00.|..549.00.|.-14.2%.| |.PrimeNum..................|.1876.00.|.1980.00.|..-5.3%.| Speedups: |.Benchmark.................|..Before.|...After.|.Speedup| |.HeapSort..................|.2962.00.|.2663.00.|..11.2%.| |.StdlibSort................|.2672.00.|.2537.00.|...5.3%.|
This commit is contained in:
@@ -98,8 +98,9 @@ SILValue SILValue::stripCasts() {
|
||||
V = stripSinglePredecessorArgs(V);
|
||||
|
||||
auto K = V->getKind();
|
||||
if (isRCIdentityPreservingCast(K) ||
|
||||
K == ValueKind::UncheckedTrivialBitCastInst) {
|
||||
if (isRCIdentityPreservingCast(K)
|
||||
|| K == ValueKind::UncheckedTrivialBitCastInst
|
||||
|| K == ValueKind::MarkDependenceInst) {
|
||||
V = cast<SILInstruction>(V.getDef())->getOperand(0);
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user