Files
swift-mirror/test/DebugInfo/conditional-assign.swift
Erik Eckstein ba4081ee76 Optimizer: replace PredictableMemoryAccessOptimizations with MandatoryRedundantLoadElimination in the pass pipeline
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
2025-02-07 11:30:35 +01:00

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
}
}