mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The problem here is that we were performing a naive negative FileCheck test for retain/release. In certain modes, we would not have any retains/releases along normal control paths but would have retains on unreachable paths. This test only is trying to test if normal code paths have this issue. To work around this issue, I created a small utility pass that prunes all non-unreachable instructions from blocks with an unreachable terminator. This is useful functionality in general when analyzing SIL since often times one will have large fatal error blocks that disguise the true behavior of the function. In this specific case, I just pipe in the normal sil output and run it through sil-opt. sil-opt then runs just the utility pass and I then FileCheck that sil-opt output. rdar://30181104
28 lines
666 B
Plaintext
28 lines
666 B
Plaintext
// RUN: %target-sil-opt -simplify-unreachable-containing-blocks -assume-parsing-unqualified-ownership-sil -module-name Swift -enable-sil-verify-all %s | %FileCheck %s
|
|
|
|
sil_stage canonical
|
|
|
|
import Builtin
|
|
|
|
enum Never {}
|
|
|
|
sil @blackhole : $@convention(thin) () -> Never
|
|
|
|
// CHECK-LABEL: sil @test1 : $@convention(thin) () -> () {
|
|
// CHECK-NOT: function_ref
|
|
// CHECK-NOT: apply
|
|
// CHECK: } // end sil function 'test1'
|
|
sil @test1 : $@convention(thin) () -> () {
|
|
bb0:
|
|
cond_br undef, bb1, bb2
|
|
|
|
bb1:
|
|
%0 = function_ref @blackhole : $@convention(thin) () -> Never
|
|
apply %0() : $@convention(thin) () -> Never
|
|
unreachable
|
|
|
|
bb2:
|
|
%9999 = tuple()
|
|
return %9999 : $()
|
|
}
|