Skip to content

Commit 5a18cf1

Browse files
committed
test: simplify the checks (NFC)
Use pointer size to determine 32-bit vs 64-bit and then check appropriately. Use a shared check to ensure that the same pattern occurs on all targets. NFC.
1 parent 7c9b6f0 commit 5a18cf1

File tree

1 file changed

+16
-35
lines changed

1 file changed

+16
-35
lines changed

test/IRGen/autorelease.sil

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -emit-ir | %FileCheck -check-prefix=%target-cpu %s
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -emit-ir | %FileCheck -check-prefix CHECK -check-prefix CHECK-%target-ptrsize -check-prefix %target-cpu %s
22

33
// rdar://16565958
44

55
import Builtin
66
import Swift
77

8-
// x86_64: [[OBJC:%objc_object]] = type
9-
// armv7: [[OBJC:%objc_object]] = type
10-
// armv7s: [[OBJC:%objc_object]] = type
11-
// armv7k: [[OBJC:%objc_object]] = type
12-
// arm64: [[OBJC:%objc_object]] = type
13-
// i386: [[OBJC:%objc_object]] = type
8+
// CHECK: [[OBJC:%objc_object]] = type
149

1510
class C {}
1611
sil_vtable C {}
@@ -24,50 +19,29 @@ sil @foo : $@convention(thin) (@owned C?) -> @autoreleased C? {
2419
bb0(%0 : @owned $C?):
2520
return %0 : $C?
2621
}
27-
// x86_64: define{{( dllexport| protected)?}} swiftcc i64 @foo(i64) {{.*}} {
28-
// x86_64: [[T0:%.*]] = tail call i64 bitcast ([[OBJC]]* ([[OBJC]]*)* @objc_autoreleaseReturnValue to i64 (i64)*)(i64 %0)
29-
// x86_64-NEXT: ret i64 [[T0]]
3022

31-
// i386: define{{( dllexport| protected)?}} swiftcc i32 @foo(i32) {{.*}} {
32-
// i386: [[T0:%.*]] = tail call i32 bitcast ([[OBJC]]* ([[OBJC]]*)* @objc_autoreleaseReturnValue to i32 (i32)*)(i32 %0)
33-
// i386-NEXT: ret i32 [[T0]]
23+
// CHECK-32: define{{( dllexport| protected)?}} swiftcc i32 @foo(i32) {{.*}} {
24+
// CHECK-32: [[T0:%.*]] = tail call i32 bitcast ([[OBJC]]* ([[OBJC]]*)* @objc_autoreleaseReturnValue to i32 (i32)*)(i32 %0)
25+
// CHECK-32-NEXT: ret i32 [[T0]]
3426

35-
// arm64: define{{( dllexport| protected)?}} swiftcc i64 @foo(i64) {{.*}} {
36-
// arm64: [[T0:%.*]] = tail call i64 bitcast ([[OBJC]]* ([[OBJC]]*)* @objc_autoreleaseReturnValue to i64 (i64)*)(i64 %0)
37-
// arm64-NEXT: ret i64 [[T0]]
38-
39-
// armv7: define{{( dllexport| protected)?}} swiftcc i32 @foo(i32) {{.*}} {
40-
// armv7: [[T0:%.*]] = tail call i32 bitcast ([[OBJC]]* ([[OBJC]]*)* @objc_autoreleaseReturnValue to i32 (i32)*)(i32 %0)
41-
// armv7-NEXT: ret i32 [[T0]]
42-
43-
// armv7s: define{{( dllexport| protected)?}} swiftcc i32 @foo(i32) {{.*}} {
44-
// armv7s: [[T0:%.*]] = tail call i32 bitcast ([[OBJC]]* ([[OBJC]]*)* @objc_autoreleaseReturnValue to i32 (i32)*)(i32 %0)
45-
// armv7s-NEXT: ret i32 [[T0]]
46-
47-
// armv7k: define{{( dllexport| protected)?}} swiftcc i32 @foo(i32) {{.*}} {
48-
// armv7k: [[T0:%.*]] = tail call i32 bitcast ([[OBJC]]* ([[OBJC]]*)* @objc_autoreleaseReturnValue to i32 (i32)*)(i32 %0)
49-
// armv7k-NEXT: ret i32 [[T0]]
27+
// CHECK-64: define{{( dllexport| protected)?}} swiftcc i64 @foo(i64) {{.*}} {
28+
// CHECK-64: [[T0:%.*]] = tail call i64 bitcast ([[OBJC]]* ([[OBJC]]*)* @objc_autoreleaseReturnValue to i64 (i64)*)(i64 %0)
29+
// CHECK-64-NEXT: ret i64 [[T0]]
5030

5131
sil @bar : $@convention(thin) (@owned C?) -> @owned C? {
5232
bb0(%0 : @owned $C?):
5333
%1 = function_ref @foo : $@convention(thin) (@owned C?) -> @autoreleased C?
5434
%2 = apply %1(%0) : $@convention(thin) (@owned C?) -> @autoreleased C?
5535
return %2 : $C?
5636
}
37+
5738
// x86_64: define{{( dllexport| protected)?}} swiftcc i64 @bar(i64)
5839
// x86_64: [[T0:%.*]] = call swiftcc i64 @foo(i64 %0)
5940
// x86_64-NEXT: [[T1:%.*]] = inttoptr i64 [[T0]] to i8*
6041
// x86_64-NEXT: [[T2:%.*]] = notail call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
6142
// x86_64-NEXT: [[T3:%.*]] = ptrtoint i8* [[T2]] to i64
6243
// x86_64-NEXT: ret i64 [[T3]]
6344

64-
// i386: define{{( dllexport| protected)?}} swiftcc i32 @bar(i32)
65-
// i386: [[T0:%.*]] = call swiftcc i32 @foo(i32 %0)
66-
// i386-NEXT: [[T1:%.*]] = inttoptr i32 [[T0]] to i8*
67-
// i386-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
68-
// i386-NEXT: [[T3:%.*]] = ptrtoint i8* [[T2]] to i32
69-
// i386-NEXT: ret i32 [[T3]]
70-
7145
// arm64: define{{( dllexport| protected)?}} swiftcc i64 @bar(i64)
7246
// arm64: [[T0:%.*]] = call swiftcc i64 @foo(i64 %0)
7347
// arm64-NEXT: call void asm sideeffect "mov
@@ -76,6 +50,13 @@ bb0(%0 : @owned $C?):
7650
// arm64-NEXT: [[T3:%.*]] = ptrtoint i8* [[T2]] to i64
7751
// arm64-NEXT: ret i64 [[T3]]
7852

53+
// i386: define{{( dllexport| protected)?}} swiftcc i32 @bar(i32)
54+
// i386: [[T0:%.*]] = call swiftcc i32 @foo(i32 %0)
55+
// i386-NEXT: [[T1:%.*]] = inttoptr i32 [[T0]] to i8*
56+
// i386-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
57+
// i386-NEXT: [[T3:%.*]] = ptrtoint i8* [[T2]] to i32
58+
// i386-NEXT: ret i32 [[T3]]
59+
7960
// armv7: define{{( dllexport| protected)?}} swiftcc i32 @bar(i32)
8061
// armv7: [[T0:%.*]] = call swiftcc i32 @foo(i32 %0)
8162
// armv7-NEXT: call void asm sideeffect "mov

0 commit comments

Comments
 (0)