Files
swift-mirror/test/SILOptimizer/simplify_branch_crash.sil
Erik Eckstein d9826f6043 SimplifyBranch: don't leave an empty block after merging two basic blocks
Although empty blocks are cleaned up at the end of every Simplification pass, it's not legal SIL to have empty blocks and subsequent simplification passes may crash because of this.

rdar://115169880
2023-09-11 14:11:46 +02:00

29 lines
747 B
Plaintext

// RUN: %target-sil-opt -enable-sil-verify-all %s -sil-opt-pass-count=1.1 -simplification -simplify-instruction=br | %FileCheck %s
// REQUIRES: swift_in_compiler
import Swift
import Builtin
// Check that branch simplification doesn't leave empty blocks.
// -sil-opt-pass-count=1.1 prevents dead block elimination which would hide the problem.
// CHECK-LABEL: sil @dont_leave_empty_blocks
// CHECK: bb0(%0 : $Builtin.Int64):
// CHECK-NEXT: br bb1
// CHECK: bb1:
// CHECK-NEXT: return %0
// CHECK: } // end sil function 'dont_leave_empty_blocks'
sil @dont_leave_empty_blocks : $@convention(thin) (Builtin.Int64) -> Builtin.Int64 {
bb0(%0 : $Builtin.Int64):
br bb1
bb1:
br bb2
bb2:
return %0 : $Builtin.Int64
}