blob: f6d1bf8d3f2056933fab339d85a748f2db8a6b10 [file] [log] [blame]
// 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 findAccessedStorage handles cyclic phis.
// <rdar://47059671> swiftc crashes
class AClass {
var aStoredProp: Builtin.Int32
}
sil @testPhiCycle : $@convention(thin) (@guaranteed AClass) -> () {
bb0(%0 : $AClass):
%accessAddr = ref_element_addr %0 : $AClass, #AClass.aStoredProp
br bbloop(%accessAddr : $*Builtin.Int32)
bbloop(%phiAddr : $*Builtin.Int32):
%access = begin_access [read] [dynamic] [no_nested_conflict] %phiAddr : $*Builtin.Int32
%val = load %access : $*Builtin.Int32
end_access %access : $*Builtin.Int32
cond_br undef, bbtail, bbreturn
bbtail:
br bbloop(%phiAddr : $*Builtin.Int32)
bbreturn:
%v = tuple ()
return %v : $()
}