Skip to content

tests: fix the immortal-arc-elimination.swift test #40286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 9 additions & 20 deletions test/SILOptimizer/immortal-arc-elimination.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// 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
// 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
// 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

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

// CHECK-SWIFT4x-LABEL: sil hidden [noinline] @$s4test10emptyArraySaySiGyF
// CHECK-SWIFT4x: global_addr
// CHECK-SWIFT4x: retain
// CHECK-SWIFT4x: } // end sil function '$s4test10emptyArraySaySiGyF'

// CHECK-SWIFT50-LABEL: sil hidden [noinline] @$s4test10emptyArraySaySiGyF
// CHECK-SWIFT50: global_addr
// CHECK-SWIFT50-NOT: retain
// CHECK-SWIFT50: } // end sil function '$s4test10emptyArraySaySiGyF'
// CHECK-LABEL: sil hidden [noinline] @$s4test10emptyArraySaySiGyF
// CHECK: global_addr
// CHECK-NOT: retain
// CHECK: } // end sil function '$s4test10emptyArraySaySiGyF'
@inline(never)
func emptyArray() -> [Int] {
let x = [Int]()
return x
}

// CHECK-SWIFT4x-LABEL: sil hidden [noinline] @$s4test13constantArraySaySiGyF
// CHECK-SWIFT4x: global_value
// CHECK-SWIFT4x: retain
// CHECK-SWIFT4x: } // end sil function '$s4test13constantArraySaySiGyF'

// CHECK-SWIFT50-LABEL: sil hidden [noinline] @$s4test13constantArraySaySiGyF
// CHECK-SWIFT50: global_value
// CHECK-SWIFT50-NOT: retain
// CHECK-SWIFT50: } // end sil function '$s4test13constantArraySaySiGyF'
// CHECK-LABEL: sil hidden [noinline] @$s4test13constantArraySaySiGyF
// CHECK: global_value
// CHECK-NOT: retain
// CHECK: } // end sil function '$s4test13constantArraySaySiGyF'
@inline(never)
func constantArray() -> [Int] {
return [1, 2, 3]
Expand Down
29 changes: 29 additions & 0 deletions test/SILOptimizer/no-immortal-arc-elimination.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// 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

// REQUIRES: OS=macosx
// REQUIRES: CPU=x86_64
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
// REQUIRES: libswift

// Check that the optimizer does not remove "unbalanced" retains for immortal objects
// prior to a Swift 5.1 runtime (which does not support immortal objects).

// CHECK-LABEL: sil hidden [noinline] @$s4test10emptyArraySaySiGyF
// CHECK: global_addr
// CHECK: retain
// CHECK: } // end sil function '$s4test10emptyArraySaySiGyF'
@inline(never)
func emptyArray() -> [Int] {
let x = [Int]()
return x
}

// CHECK-LABEL: sil hidden [noinline] @$s4test13constantArraySaySiGyF
// CHECK: global_value
// CHECK: retain
// CHECK: } // end sil function '$s4test13constantArraySaySiGyF'
@inline(never)
func constantArray() -> [Int] {
return [1, 2, 3]
}