Skip to content

Commit efb70c1

Browse files
committed
test: enable SILOptimizer.definite-init-wrongscope
This was matching the wrong `throw` as the scope was incorrect. Correct the scope which allows us to match the correct `throw` and enable the test on Windows. While here, add an additional check for the `destroy_addr`, `dealloc_stack` to match the regular exit which is duplicated in the throwing block. Add an additional check to ensure that we do not escape the bounds of the function. Thanks to @adrian-prantl for helping ensure that the changes here are valid! Fixes: SR-14267
1 parent b39ba6c commit efb70c1

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

test/SILOptimizer/definite-init-wrongscope.swift

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
// RUN: -sil-print-functions=$s3del1MC4fromAcA12WithDelegate_p_tKcfc \
44
// RUN: -Xllvm -sil-print-debuginfo -o /dev/null -module-name del 2>&1 | %FileCheck %s
55

6-
// Unsupported on Windows due to SR-14267
7-
// UNSUPPORTED: OS=windows-msvc
8-
96
public protocol DelegateA {}
107
public protocol DelegateB {}
118
public protocol WithDelegate
@@ -33,14 +30,18 @@ public class M {
3330

3431
// CHECK-LABEL: sil [ossa] @$s3del1MC4fromAcA12WithDelegate_p_tKcfc : $@convention(method) (@in WithDelegate, @owned M) -> (@owned M, @error Error)
3532

36-
// CHECK: [[I:%.*]] = integer_literal $Builtin.Int2, 1, loc {{.*}}:23:12, scope 5
37-
// CHECK: [[V:%.*]] = load [trivial] %2 : $*Builtin.Int2, loc {{.*}}:23:12, scope 5
38-
// CHECK: [[OR:%.*]] = builtin "or_Int2"([[V]] : $Builtin.Int2, [[I]] : $Builtin.Int2) : $Builtin.Int2, loc {{.*}}:23:12, scope 5
39-
// CHECK: store [[OR]] to [trivial] %2 : $*Builtin.Int2, loc {{.*}}:23:12, scope 5
40-
// CHECK: store %{{.*}} to [init] %{{.*}} : $*C, loc {{.*}}:26:20, scope 5
33+
// CHECK: [[I:%.*]] = integer_literal $Builtin.Int2, 1, loc {{.*}}:20:12, scope 5
34+
// CHECK: [[V:%.*]] = load [trivial] %2 : $*Builtin.Int2, loc {{.*}}:20:12, scope 5
35+
// CHECK: [[OR:%.*]] = builtin "or_Int2"([[V]] : $Builtin.Int2, [[I]] : $Builtin.Int2) : $Builtin.Int2, loc {{.*}}:20:12, scope 5
36+
// CHECK: store [[OR]] to [trivial] %2 : $*Builtin.Int2, loc {{.*}}:20:12, scope 5
37+
// CHECK: store %{{.*}} to [init] %{{.*}} : $*C, loc {{.*}}:23:20, scope 5
4138

4239
// Make sure the dealloc_stack gets the same scope of the instructions surrounding it.
4340

44-
// CHECK: destroy_addr %0 : $*WithDelegate, loc {{.*}}:29:5, scope 5
45-
// CHECK: dealloc_stack %2 : $*Builtin.Int2, loc {{.*}}:23:12, scope 5
46-
// CHECK: throw %{{.*}} : $Error, loc {{.*}}:23:12, scope 1
41+
// CHECK: destroy_addr %0 : $*WithDelegate, loc {{.*}}:26:5, scope 5
42+
// CHECK-NEXT: dealloc_stack %2 : $*Builtin.Int2, loc {{.*}}:20:12, scope 5
43+
44+
// CHECK: destroy_addr %0 : $*WithDelegate, loc {{.*}}:26:5, scope 5
45+
// CHECK-NEXT: dealloc_stack %2 : $*Builtin.Int2, loc {{.*}}:20:12, scope 5
46+
// CHECK-NEXT: throw %{{.*}} : $Error, loc {{.*}}:26:5, scope 5
47+
// CHECK: end sil function '$s3del1MC4fromAcA12WithDelegate_p_tKcfc'

0 commit comments

Comments
 (0)