Skip to content

Commit

Permalink
[IRGen][Test] Update tests for non-Linux platform support.
Browse files Browse the repository at this point in the history
Tweak the tests slightly for WASM, Windows and Darwin.

rdar://23335318
  • Loading branch information
al45tair committed Mar 1, 2024
1 parent d0c35cf commit 8d6783d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
2 changes: 2 additions & 0 deletions test/IRGen/autorelease.sil
@@ -1,5 +1,7 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) %s -enable-objc-interop -emit-ir | %FileCheck -check-prefix CHECK -check-prefix CHECK-%target-ptrsize -check-prefix %target-cpu -DINT=i%target-ptrsize %s

// REQUIRES: objc_codegen

// rdar://16565958

import Builtin
Expand Down
16 changes: 6 additions & 10 deletions test/IRGen/cf_objc_retainAutoreleasedReturnValue.swift
@@ -1,5 +1,9 @@
// RUN: %target-swift-frontend -module-name cf_objc_retainAutoreleasedReturnValue -I %S/Inputs %s -enable-objc-interop -emit-ir | %FileCheck %s
// RUN: %target-swift-frontend -module-name cf_objc_retainAutoreleasedReturnValue -I %S/Inputs %s -emit-ir | %FileCheck %s --check-prefix=NO_INTEROP

// We need to require objc_codegen to avoid this test on WASM.
// (That's why the other half of this test is in a separate file.)

// REQUIRES: objc_codegen

import CFBridgedType

Expand All @@ -10,15 +14,7 @@ public func foo() {

// With interop enabled, this should use objc_retainAutoreleasedReturnValue()

// CHECK-LABEL: define protected swiftcc void @"$s37cf_objc_retainAutoreleasedReturnValue3fooyyF"()
// CHECK-LABEL: define {{.*}}swiftcc void @"$s37cf_objc_retainAutoreleasedReturnValue3fooyyF"()
// CHECK: entry:
// CHECK: %0 = call {{.*}}@returnsACFBridgedType()
// CHECK: %1 = notail call ptr @llvm.objc.retainAutoreleasedReturnValue(ptr %0)

// Without interop, it should call swift_retain() instead.

// NO_INTEROP-LABEL: define protected swiftcc void @"$s37cf_objc_retainAutoreleasedReturnValue3fooyyF"()
// NO_INTEROP: entry:
// NO_INTEROP: %0 = call {{.*}}@returnsACFBridgedType()
// NO_INTEROP: %1 = call ptr @swift_retain(ptr returned %0)

18 changes: 18 additions & 0 deletions test/IRGen/cf_objc_retainAutoreleasedReturnValue2.swift
@@ -0,0 +1,18 @@
// RUN: %target-swift-frontend -module-name cf_objc_retainAutoreleasedReturnValue -I %S/Inputs %s -disable-objc-interop -emit-ir | %FileCheck %s

// This is in a separate file because *this* one works on WASM.
// (cf_objc_retainAutoreleasedReturnValue.swift does not.)

import CFBridgedType

@inline(never)
public func foo() {
let _ = returnsACFBridgedType()
}

// With interop disabled, this should use swift_retain().

// CHECK-LABEL: define {{.*}}swiftcc void @"$s37cf_objc_retainAutoreleasedReturnValue3fooyyF"()
// CHECK: entry:
// CHECK: %0 = call {{.*}}@returnsACFBridgedType()
// CHECK: %1 = call ptr @swift_retain(ptr returned %0)

0 comments on commit 8d6783d

Please sign in to comment.