Skip to content

test: simplify the checks (NFC) #19718

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
Oct 4, 2018
Merged
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
51 changes: 16 additions & 35 deletions test/IRGen/autorelease.sil
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -emit-ir | %FileCheck -check-prefix=%target-cpu %s
// 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

// rdar://16565958

import Builtin
import Swift

// x86_64: [[OBJC:%objc_object]] = type
// armv7: [[OBJC:%objc_object]] = type
// armv7s: [[OBJC:%objc_object]] = type
// armv7k: [[OBJC:%objc_object]] = type
// arm64: [[OBJC:%objc_object]] = type
// i386: [[OBJC:%objc_object]] = type
// CHECK: [[OBJC:%objc_object]] = type

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

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

// arm64: define{{( dllexport| protected)?}} swiftcc i64 @foo(i64) {{.*}} {
// arm64: [[T0:%.*]] = tail call i64 bitcast ([[OBJC]]* ([[OBJC]]*)* @objc_autoreleaseReturnValue to i64 (i64)*)(i64 %0)
// arm64-NEXT: ret i64 [[T0]]

// armv7: define{{( dllexport| protected)?}} swiftcc i32 @foo(i32) {{.*}} {
// armv7: [[T0:%.*]] = tail call i32 bitcast ([[OBJC]]* ([[OBJC]]*)* @objc_autoreleaseReturnValue to i32 (i32)*)(i32 %0)
// armv7-NEXT: ret i32 [[T0]]

// armv7s: define{{( dllexport| protected)?}} swiftcc i32 @foo(i32) {{.*}} {
// armv7s: [[T0:%.*]] = tail call i32 bitcast ([[OBJC]]* ([[OBJC]]*)* @objc_autoreleaseReturnValue to i32 (i32)*)(i32 %0)
// armv7s-NEXT: ret i32 [[T0]]

// armv7k: define{{( dllexport| protected)?}} swiftcc i32 @foo(i32) {{.*}} {
// armv7k: [[T0:%.*]] = tail call i32 bitcast ([[OBJC]]* ([[OBJC]]*)* @objc_autoreleaseReturnValue to i32 (i32)*)(i32 %0)
// armv7k-NEXT: ret i32 [[T0]]
// CHECK-64: define{{( dllexport| protected)?}} swiftcc i64 @foo(i64) {{.*}} {
// CHECK-64: [[T0:%.*]] = tail call i64 bitcast ([[OBJC]]* ([[OBJC]]*)* @objc_autoreleaseReturnValue to i64 (i64)*)(i64 %0)
// CHECK-64-NEXT: ret i64 [[T0]]

sil @bar : $@convention(thin) (@owned C?) -> @owned C? {
bb0(%0 : @owned $C?):
%1 = function_ref @foo : $@convention(thin) (@owned C?) -> @autoreleased C?
%2 = apply %1(%0) : $@convention(thin) (@owned C?) -> @autoreleased C?
return %2 : $C?
}

// x86_64: define{{( dllexport| protected)?}} swiftcc i64 @bar(i64)
// x86_64: [[T0:%.*]] = call swiftcc i64 @foo(i64 %0)
// x86_64-NEXT: [[T1:%.*]] = inttoptr i64 [[T0]] to i8*
// x86_64-NEXT: [[T2:%.*]] = notail call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
// x86_64-NEXT: [[T3:%.*]] = ptrtoint i8* [[T2]] to i64
// x86_64-NEXT: ret i64 [[T3]]

// i386: define{{( dllexport| protected)?}} swiftcc i32 @bar(i32)
// i386: [[T0:%.*]] = call swiftcc i32 @foo(i32 %0)
// i386-NEXT: [[T1:%.*]] = inttoptr i32 [[T0]] to i8*
// i386-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
// i386-NEXT: [[T3:%.*]] = ptrtoint i8* [[T2]] to i32
// i386-NEXT: ret i32 [[T3]]

// arm64: define{{( dllexport| protected)?}} swiftcc i64 @bar(i64)
// arm64: [[T0:%.*]] = call swiftcc i64 @foo(i64 %0)
// arm64-NEXT: call void asm sideeffect "mov
Expand All @@ -76,6 +50,13 @@ bb0(%0 : @owned $C?):
// arm64-NEXT: [[T3:%.*]] = ptrtoint i8* [[T2]] to i64
// arm64-NEXT: ret i64 [[T3]]

// i386: define{{( dllexport| protected)?}} swiftcc i32 @bar(i32)
// i386: [[T0:%.*]] = call swiftcc i32 @foo(i32 %0)
// i386-NEXT: [[T1:%.*]] = inttoptr i32 [[T0]] to i8*
// i386-NEXT: [[T2:%.*]] = call i8* @objc_retainAutoreleasedReturnValue(i8* [[T1]])
// i386-NEXT: [[T3:%.*]] = ptrtoint i8* [[T2]] to i32
// i386-NEXT: ret i32 [[T3]]

// armv7: define{{( dllexport| protected)?}} swiftcc i32 @bar(i32)
// armv7: [[T0:%.*]] = call swiftcc i32 @foo(i32 %0)
// armv7-NEXT: call void asm sideeffect "mov
Expand Down