Skip to content

Commit 2a9c148

Browse files
authored
Merge pull request #40286 from eeckstein/fix-immortal-arc-test
tests: fix the immortal-arc-elimination.swift test
2 parents abaa58b + 2264668 commit 2a9c148

File tree

2 files changed

+38
-20
lines changed

2 files changed

+38
-20
lines changed

test/SILOptimizer/immortal-arc-elimination.swift

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// RUN: %target-swift-frontend -primary-file %s -O -sil-verify-all -Xllvm -sil-disable-pass=function-signature-opts -module-name=test -O -target %target-cpu-apple-macos10.14 -emit-sil | %FileCheck --check-prefix=CHECK-SWIFT4x %s
2-
// RUN: %target-swift-frontend -primary-file %s -O -sil-verify-all -Xllvm -sil-disable-pass=function-signature-opts -module-name=test -O -target %target-cpu-apple-macos10.15 -emit-sil | %FileCheck --check-prefix=CHECK-SWIFT50 %s
1+
// RUN: %target-swift-frontend -primary-file %s -O -sil-verify-all -Xllvm -sil-disable-pass=function-signature-opts -module-name=test -O -target %target-cpu-apple-macos10.15 -emit-sil | %FileCheck %s
32

43
// RUN: %empty-directory(%t)
54
// RUN: %target-build-swift -O -Xllvm -sil-disable-pass=function-signature-opts -module-name=test %s -o %t/a.out
@@ -12,30 +11,20 @@
1211
// Check that the optimizer can remove "unbalanced" retains for immortal objects.
1312
// But only with a Swift 5.1 runtime (which supports immortal objects).
1413

15-
// CHECK-SWIFT4x-LABEL: sil hidden [noinline] @$s4test10emptyArraySaySiGyF
16-
// CHECK-SWIFT4x: global_addr
17-
// CHECK-SWIFT4x: retain
18-
// CHECK-SWIFT4x: } // end sil function '$s4test10emptyArraySaySiGyF'
19-
20-
// CHECK-SWIFT50-LABEL: sil hidden [noinline] @$s4test10emptyArraySaySiGyF
21-
// CHECK-SWIFT50: global_addr
22-
// CHECK-SWIFT50-NOT: retain
23-
// CHECK-SWIFT50: } // end sil function '$s4test10emptyArraySaySiGyF'
14+
// CHECK-LABEL: sil hidden [noinline] @$s4test10emptyArraySaySiGyF
15+
// CHECK: global_addr
16+
// CHECK-NOT: retain
17+
// CHECK: } // end sil function '$s4test10emptyArraySaySiGyF'
2418
@inline(never)
2519
func emptyArray() -> [Int] {
2620
let x = [Int]()
2721
return x
2822
}
2923

30-
// CHECK-SWIFT4x-LABEL: sil hidden [noinline] @$s4test13constantArraySaySiGyF
31-
// CHECK-SWIFT4x: global_value
32-
// CHECK-SWIFT4x: retain
33-
// CHECK-SWIFT4x: } // end sil function '$s4test13constantArraySaySiGyF'
34-
35-
// CHECK-SWIFT50-LABEL: sil hidden [noinline] @$s4test13constantArraySaySiGyF
36-
// CHECK-SWIFT50: global_value
37-
// CHECK-SWIFT50-NOT: retain
38-
// CHECK-SWIFT50: } // end sil function '$s4test13constantArraySaySiGyF'
24+
// CHECK-LABEL: sil hidden [noinline] @$s4test13constantArraySaySiGyF
25+
// CHECK: global_value
26+
// CHECK-NOT: retain
27+
// CHECK: } // end sil function '$s4test13constantArraySaySiGyF'
3928
@inline(never)
4029
func constantArray() -> [Int] {
4130
return [1, 2, 3]
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %target-swift-frontend -primary-file %s -O -sil-verify-all -Xllvm -sil-disable-pass=function-signature-opts -module-name=test -O -target %target-cpu-apple-macos10.14 -emit-sil | %FileCheck %s
2+
3+
// REQUIRES: OS=macosx
4+
// REQUIRES: CPU=x86_64
5+
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
6+
// REQUIRES: libswift
7+
8+
// Check that the optimizer does not remove "unbalanced" retains for immortal objects
9+
// prior to a Swift 5.1 runtime (which does not support immortal objects).
10+
11+
// CHECK-LABEL: sil hidden [noinline] @$s4test10emptyArraySaySiGyF
12+
// CHECK: global_addr
13+
// CHECK: retain
14+
// CHECK: } // end sil function '$s4test10emptyArraySaySiGyF'
15+
@inline(never)
16+
func emptyArray() -> [Int] {
17+
let x = [Int]()
18+
return x
19+
}
20+
21+
// CHECK-LABEL: sil hidden [noinline] @$s4test13constantArraySaySiGyF
22+
// CHECK: global_value
23+
// CHECK: retain
24+
// CHECK: } // end sil function '$s4test13constantArraySaySiGyF'
25+
@inline(never)
26+
func constantArray() -> [Int] {
27+
return [1, 2, 3]
28+
}
29+

0 commit comments

Comments
 (0)