mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
PredictableMemoryAccessOptimizations has become unmaintainable as-is. RedundantLoadElimination does (almost) the same thing as PredictableMemoryAccessOptimizations. It's not as powerful but good enough because PredictableMemoryAccessOptimizations is actually only needed for promoting integer values for mandatory constant propagation. And most importantly: RedundantLoadElimination does not insert additional copies which was a big problem in PredictableMemoryAccessOptimizations. Fixes rdar://142814676
31 lines
940 B
Swift
31 lines
940 B
Swift
// RUN: %target-swift-frontend %s -Xllvm -sil-print-debuginfo -emit-sil -g -o - | %FileCheck %s
|
|
public protocol DelegateA {}
|
|
public protocol DelegateB {}
|
|
public protocol WithDelegate
|
|
{
|
|
var delegate: DelegateA? { get }
|
|
func f() throws -> Int
|
|
}
|
|
public enum Err: Swift.Error {
|
|
case s(Int)
|
|
}
|
|
public class C {}
|
|
public class M {
|
|
let field: C
|
|
var value : Int
|
|
// Verify that definite initialization doesn't create a bogus description of
|
|
// self pointing to the liveness bitvector.
|
|
|
|
// CHECK-LABEL: sil @$s4main1MC4fromAcA12WithDelegate_p_tKcfc
|
|
// CHECK: bb0
|
|
// CHECK-NOT: alloc_stack $Builtin.Int2{{.*}}let
|
|
// CHECK: } // end sil function '$s4main1MC4fromAcA12WithDelegate_p_tKcfc'
|
|
public init(from d: WithDelegate) throws {
|
|
guard let delegate = d.delegate as? DelegateB
|
|
else { throw Err.s(0) }
|
|
self.field = C()
|
|
let i: Int = try d.f()
|
|
value = i
|
|
}
|
|
}
|