mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
110 lines
2.0 KiB
Plaintext
110 lines
2.0 KiB
Plaintext
// RUN: %target-sil-opt -enable-sil-verify-all %s
|
|
|
|
// REQUIRES: asserts
|
|
|
|
// This file is meant to pass the verifier.
|
|
|
|
import Builtin
|
|
|
|
sil_stage canonical
|
|
|
|
// Don't fail in the verifier on a shared unreachable exit block of two loops.
|
|
sil @dont_fail: $@convention(thin) (Builtin.Int1) -> () {
|
|
bb0(%0 : $Builtin.Int1):
|
|
%2 = integer_literal $Builtin.Int1, -1
|
|
cond_br %0, bb1, bb5
|
|
|
|
// Loop.
|
|
bb1:
|
|
%4 = alloc_stack $Builtin.Int32
|
|
cond_br %0, bb2, bb3
|
|
|
|
bb2:
|
|
dealloc_stack %4 : $*Builtin.Int32
|
|
cond_br %0, bb4, bb1
|
|
|
|
// Cloned loop.
|
|
bb5:
|
|
%6 = alloc_stack $Builtin.Int32
|
|
cond_br %0, bb6, bb3
|
|
|
|
bb6:
|
|
dealloc_stack %6 : $*Builtin.Int32
|
|
cond_br %0, bb4, bb5
|
|
|
|
// Shared unreachable exit block.
|
|
bb3:
|
|
cond_fail %2 : $Builtin.Int1
|
|
unreachable
|
|
|
|
bb4:
|
|
%10 = tuple ()
|
|
return %10 : $()
|
|
}
|
|
|
|
|
|
sil @dont_fail2: $@convention(thin) (Builtin.Int1) -> () {
|
|
bb0(%0 : $Builtin.Int1):
|
|
%2 = integer_literal $Builtin.Int1, -1
|
|
cond_br %0, bb1, bb5
|
|
|
|
// Loop.
|
|
bb1:
|
|
%4 = alloc_stack $Builtin.Int32
|
|
cond_br %0, bb2, bb3
|
|
|
|
bb2:
|
|
dealloc_stack %4 : $*Builtin.Int32
|
|
cond_br %0, bb4, bb1
|
|
|
|
// Cloned loop.
|
|
bb5:
|
|
%6 = alloc_stack $Builtin.Int32
|
|
cond_br %0, bb6, bb3
|
|
|
|
bb6:
|
|
dealloc_stack %6 : $*Builtin.Int32
|
|
cond_br %0, bb4, bb5
|
|
|
|
// Shared unreachable exit block.
|
|
bb3:
|
|
cond_br %0, bb7, bb8
|
|
|
|
bb7:
|
|
cond_fail %2 : $Builtin.Int1
|
|
unreachable
|
|
|
|
bb8:
|
|
cond_fail %2 : $Builtin.Int1
|
|
unreachable
|
|
|
|
bb4:
|
|
%10 = tuple ()
|
|
return %10 : $()
|
|
}
|
|
|
|
// Verify that identifyFormalAccess handles cyclic phis.
|
|
// <rdar://47059671> swiftc crashes
|
|
class AClass {
|
|
var aStoredProp: Builtin.Int32
|
|
}
|
|
|
|
sil @testPhiCycle : $@convention(thin) (@guaranteed AClass) -> () {
|
|
bb0(%0 : $AClass):
|
|
br bbloop
|
|
|
|
bbloop:
|
|
%accessAddr = ref_element_addr %0 : $AClass, #AClass.aStoredProp
|
|
%access = begin_access [read] [dynamic] [no_nested_conflict] %accessAddr : $*Builtin.Int32
|
|
%val = load %access : $*Builtin.Int32
|
|
end_access %access : $*Builtin.Int32
|
|
cond_br undef, bbtail, bbreturn
|
|
|
|
bbtail:
|
|
br bbloop
|
|
|
|
bbreturn:
|
|
%v = tuple ()
|
|
return %v : $()
|
|
}
|