Skip to content

Commit bb9c44f

Browse files
committed
SILOptimizer: Fix a broken test
The test only passed on accident with -O prior to the '@NoReturn -> Never' change, because '@NoReturn' in a function_ref matched the 'CHECK: return' line. Make the CHECK: more specific, which even before my changes exposes that there was a strong_retain in there in optimized builds. Fixes <rdar://problem/27506150>.
1 parent d138290 commit bb9c44f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

test/SILOptimizer/swap_refcnt.swift

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
// RUN: %target-swift-frontend -O -emit-sil %s | FileCheck %s
2-
// REQUIRES: rdar:27506150> SILOptimizer/swap_refcnt.swift failes after noreturn -> Never changes
32

43
// Make sure we can swap two values in an array without retaining anything.
54

5+
// FIXME: In optimized builds, we inline some stuff, and end up with
6+
// the following instruction sequence -- %130 is a never-returning
7+
// function:
8+
//
9+
// strong_retain %23 : $Builtin.NativeObject
10+
// strong_retain %23 : $Builtin.NativeObject
11+
// strong_retain %23 : $Builtin.NativeObject
12+
// %130 = apply %121(%125, %114, %118, %120, %126)
13+
//
14+
// But really the strong_retains here should be optimized away.
15+
16+
// REQUIRES: swift_test_mode_optimize_none
17+
18+
619
// CHECK-LABEL: sil @_TF11swap_refcnt11swapByIndex
720
// CHECK-NOT: strong_retain
821
// CHECK-NOT: strong_release
9-
// CHECK: return
22+
// CHECK: return %
1023
public func swapByIndex(A: inout [Int8], x : Int, y : Int) {
1124
swap(&A[x],&A[y])
1225
}

0 commit comments

Comments
 (0)