Skip to content

Commit 7c94216

Browse files
committed
[Apple Silicon] [Test] Fix various IRGen tests for arm64 macOS
1 parent 16110be commit 7c94216

File tree

7 files changed

+39
-27
lines changed

7 files changed

+39
-27
lines changed

test/IRGen/abitypes.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import Foundation
1717
// arm64e-ios: [[ARM64E_MYRECT:%.*]] = type { float, float, float, float }
1818
// arm64-tvos: [[ARM64_MYRECT:%.*]] = type { float, float, float, float }
1919
// armv7k-watchos: [[ARMV7K_MYRECT:%.*]] = type { float, float, float, float }
20+
// arm64-macosx: [[ARM64E_MYRECT:%.*]] = type { float, float, float, float }
2021

2122
class Foo {
2223
// x86_64-macosx: define hidden swiftcc { float, float, float, float } @"$s8abitypes3FooC3bar{{[_0-9a-zA-Z]*}}F"(%T8abitypes3FooC* swiftself %0) {{.*}} {
@@ -428,7 +429,12 @@ class Foo {
428429
// armv7k-watchos: [[TOOBJCBOOL:%[0-9]+]] = call swiftcc i1 @"$s10ObjectiveC22_convertBoolToObjCBool{{[_0-9a-zA-Z]*}}F"(i1 [[NEG]])
429430
// armv7k-watchos: ret i1 [[TOOBJCBOOL]]
430431
//
431-
@objc dynamic func negate2(_ b: Bool) -> Bool {
432+
433+
// arm64-macosx: define hidden zeroext i1 @"$s8abitypes3FooC7negate2{{[_0-9a-zA-Z]*}}FTo"(i8* %0, i8* %1, i1 zeroext %2)
434+
// arm64-macosx: [[NEG:%[0-9]+]] = call swiftcc i1 @"$s8abitypes3FooC7negate2{{[_0-9a-zA-Z]*}}F"(i1
435+
// arm64-macosx: [[TOOBJCBOOL:%[0-9]+]] = call swiftcc i1 @"$s10ObjectiveC22_convertBoolToObjCBool{{[_0-9a-zA-Z]*}}F"(i1 [[NEG]])
436+
// arm64-macosx: ret i1 [[TOOBJCBOOL]]
437+
@objc dynamic func negate2(_ b: Bool) -> Bool {
432438
var g = Gadget()
433439
return g.negate(b)
434440
}
@@ -532,6 +538,8 @@ class Foo {
532538
//
533539
// arm64-tvos: define hidden swiftcc { i64, i64, i64, i64 } @"$s8abitypes3FooC14callJustReturn{{[_0-9a-zA-Z]*}}F"(%TSo13StructReturnsC* %0, i64 %1, i64 %2, i64 %3, i64 %4, %T8abitypes3FooC* swiftself %5) {{.*}} {
534540
// arm64-tvos: define hidden void @"$s8abitypes3FooC14callJustReturn{{[_0-9a-zA-Z]*}}FTo"(%TSo9BigStructV* noalias nocapture sret %0, i8* %1, i8* %2, [[OPAQUE:.*]]* %3, %TSo9BigStructV* %4) {{[#0-9]*}} {
541+
// arm64-macosx: define hidden swiftcc { i64, i64, i64, i64 } @"$s8abitypes3FooC14callJustReturn{{[_0-9a-zA-Z]*}}F"(%TSo13StructReturnsC* %0, i64 %1, i64 %2, i64 %3, i64 %4, %T8abitypes3FooC* swiftself %5) {{.*}} {
542+
// arm64-macosx: define hidden void @"$s8abitypes3FooC14callJustReturn{{[_0-9a-zA-Z]*}}FTo"(%TSo9BigStructV* noalias nocapture sret %0, i8* %1, i8* %2, [[OPAQUE:.*]]* %3, %TSo9BigStructV* %4) {{.*}} {
535543
@objc dynamic func callJustReturn(_ r: StructReturns, with v: BigStruct) -> BigStruct {
536544
return r.justReturn(v)
537545
}
@@ -585,6 +593,15 @@ public func testInlineAgg(_ rect: MyRect) -> Float {
585593
// arm64e-ios: store i1 false, i1* [[PTR2]], align 8
586594
// arm64e-ios: [[ARG:%.*]] = load i64, i64* [[COERCED]]
587595
// arm64e-ios: call void bitcast (void ()* @objc_msgSend to void (i8*, i8*, i64)*)(i8* {{.*}}, i8* {{.*}}, i64 [[ARG]])
596+
// arm64-macosx: define swiftcc void @"$s8abitypes14testBOOLStructyyF"()
597+
// arm64-macosx: [[COERCED:%.*]] = alloca i64
598+
// arm64-macosx: [[STRUCTPTR:%.*]] = bitcast i64* [[COERCED]] to %TSo14FiveByteStructV
599+
// arm64-macosx: [[PTR0:%.*]] = getelementptr inbounds %TSo14FiveByteStructV, %TSo14FiveByteStructV* [[STRUCTPTR]], {{i.*}} 0, {{i.*}} 0
600+
// arm64-macosx: [[PTR1:%.*]] = getelementptr inbounds %T10ObjectiveC8ObjCBoolV, %T10ObjectiveC8ObjCBoolV* [[PTR0]], {{i.*}} 0, {{i.*}} 0
601+
// arm64-macosx: [[PTR2:%.*]] = getelementptr inbounds %TSb, %TSb* [[PTR1]], {{i.*}} 0, {{i.*}} 0
602+
// arm64-macosx: store i1 false, i1* [[PTR2]], align 8
603+
// arm64-macosx: [[ARG:%.*]] = load i64, i64* [[COERCED]]
604+
// arm64-macosx: call void bitcast (void ()* @objc_msgSend to void (i8*, i8*, i64)*)(i8* {{.*}}, i8* {{.*}}, i64 [[ARG]])
588605
public func testBOOLStruct() {
589606
let s = FiveByteStruct()
590607
MyClass.mymethod(s)

test/IRGen/conditional_conformances_gettypemetdatabyname.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-swift-frontend -disable-generic-metadata-prespecialization -target x86_64-apple-macosx10.99 -emit-ir %S/../Inputs/conditional_conformance_basic_conformances.swift | %FileCheck %S/../Inputs/conditional_conformance_basic_conformances.swift --check-prefix=TYPEBYNAME
2-
// RUN: %target-swift-frontend -prespecialize-generic-metadata -target x86_64-apple-macosx10.99 -emit-ir %S/../Inputs/conditional_conformance_basic_conformances.swift | %FileCheck %S/../Inputs/conditional_conformance_basic_conformances.swift --check-prefix=TYPEBYNAME_PRESPECIALIZED
1+
// RUN: %target-swift-frontend -disable-generic-metadata-prespecialization -target %target-cpu-apple-macosx10.99 -emit-ir %S/../Inputs/conditional_conformance_basic_conformances.swift | %FileCheck %S/../Inputs/conditional_conformance_basic_conformances.swift --check-prefix=TYPEBYNAME
2+
// RUN: %target-swift-frontend -prespecialize-generic-metadata -target %target-cpu-apple-macosx10.99 -emit-ir %S/../Inputs/conditional_conformance_basic_conformances.swift | %FileCheck %S/../Inputs/conditional_conformance_basic_conformances.swift --check-prefix=TYPEBYNAME_PRESPECIALIZED
33

44
// Too many pointer-sized integers in the IR
55
// REQUIRES: PTRSIZE=64

test/IRGen/metadata.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ enum Singleton {
1010

1111
// CHECK: @"$s1A1GC14zeroSizedFieldAA9SingletonOvpWvd" = hidden constant i{{(64|32)}} 0
1212
// Check that the instance start is after the header (at 8 or 16).
13-
// CHECK-macosx: _DATA__TtC1A1G = private constant {{.*}} { i32 128, i32 {{(16|8)}}
13+
// CHECK-macosx: _DATA__TtC1A1G = private constant {{.*}} { i32 {{(128|129)}}, i32 {{(16|8|40)}}
1414
// CHECK-ios: _DATA__TtC1A1G = private constant {{.*}} { i32 {{(128|129)}}, i32 {{(16|8|40)}}
1515
// CHECK-watchos: _DATA__TtC1A1G = private constant {{.*}} { i32 128, i32 {{(16|8)}}
1616
// CHECK-tvos: _DATA__TtC1A1G = private constant {{.*}} { i32 128, i32 {{(16|8)}}

test/IRGen/objc_properties.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class SomeWrapperTests {
118118
// CHECK-SAME: i32 {{[0-9]+}}, i32 {{[0-9]+}}, i32 {{[0-9]+}}, i32 {{[0-9]+}},
119119
// CHECK-SAME: i8* null,
120120
// CHECK-SAME: i8* getelementptr inbounds ([{{.+}} x i8], [{{.+}} x i8]* {{@.+}}, i64 0, i64 0),
121-
// CHECK-SAME: { {{.+}} }* @_CLASS_METHODS__TtC15objc_properties10SomeObject,
121+
// CHECK-SAME: { {{.+}} }* @_CLASS_METHODS__TtC15objc_properties10SomeObject{{(\.ptrauth)?}}
122122
// CHECK-SAME: i8* null, i8* null, i8* null,
123123
// CHECK-NEW-SAME: { {{.+}} }* @_CLASS_PROPERTIES__TtC15objc_properties10SomeObject
124124
// CHECK-OLD-SAME: i8* null
@@ -201,7 +201,7 @@ class SomeWrapperTests {
201201
// CHECK: i32 {{[0-9]+}}, i32 {{[0-9]+}}, i32 {{[0-9]+}}, i32 {{[0-9]+}},
202202
// CHECK: i8* null,
203203
// CHECK: i8* getelementptr inbounds ([{{.+}} x i8], [{{.+}} x i8]* {{@.+}}, i64 0, i64 0),
204-
// CHECK: { {{.+}} }* @_INSTANCE_METHODS__TtC15objc_properties10SomeObject,
204+
// CHECK: { {{.+}} }* @_INSTANCE_METHODS__TtC15objc_properties10SomeObject{{(\.ptrauth)?}}
205205
// CHECK: i8* null,
206206
// CHECK: { {{.+}} }* @_IVARS__TtC15objc_properties10SomeObject,
207207
// CHECK: i8* null,
@@ -251,10 +251,10 @@ class SomeWrapperTests {
251251
// CHECK: @"_CATEGORY__TtC15objc_properties10SomeObject_$_objc_properties" = private constant { {{.+}} } {
252252
// CHECK: i8* getelementptr inbounds ([{{.+}} x i8], [{{.+}} x i8]* {{@.+}}, i64 0, i64 0),
253253
// CHECK: %swift.type* bitcast (i64* getelementptr inbounds (<{ {{.+}} }>* @"$s15objc_properties10SomeObjectCMf", i32 0, i32 2) to %swift.type*),
254-
// CHECK: { {{.+}} }* @"_CATEGORY_INSTANCE_METHODS__TtC15objc_properties10SomeObject_$_objc_properties",
255-
// CHECK: { {{.+}} }* @"_CATEGORY_CLASS_METHODS__TtC15objc_properties10SomeObject_$_objc_properties",
254+
// CHECK: { {{.+}} }* @"_CATEGORY_INSTANCE_METHODS__TtC15objc_properties10SomeObject_$_objc_properties{{(\.ptrauth)?}}"
255+
// CHECK: { {{.+}} }* @"_CATEGORY_CLASS_METHODS__TtC15objc_properties10SomeObject_$_objc_properties{{(\.ptrauth)?}}"
256256
// CHECK: i8* null,
257-
// CHECK: { {{.+}} }* @"_CATEGORY_PROPERTIES__TtC15objc_properties10SomeObject_$_objc_properties",
257+
// CHECK: { {{.+}} }* @"_CATEGORY_PROPERTIES__TtC15objc_properties10SomeObject_$_objc_properties{{(\.ptrauth)?}}",
258258
// CHECK-NEW: { {{.+}} }* @"_CATEGORY_CLASS_PROPERTIES__TtC15objc_properties10SomeObject_$_objc_properties",
259259
// CHECK-OLD: i8* null,
260260
// CHECK: i32 60

test/IRGen/opaque_result_type_availability.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -enable-implicit-dynamic -target %target-cpu-apple-macosx10.9 -Onone -emit-ir %s | %FileCheck --check-prefix=MAYBE-AVAILABLE %s
1+
// RUN: %target-swift-frontend -enable-implicit-dynamic -target x86_64-apple-macosx10.9 -Onone -emit-ir %s | %FileCheck --check-prefix=MAYBE-AVAILABLE %s
22
// RUN: %target-swift-frontend -enable-implicit-dynamic -target %target-cpu-apple-macosx10.15 -Onone -emit-ir %s | %FileCheck --check-prefix=ALWAYS-AVAILABLE %s
33
// REQUIRES: OS=macosx
44

test/Inputs/clang-importer-sdk/swift-modules/ObjectiveC.swift

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,33 @@
22

33
// The iOS/arm64 target uses _Bool for Objective-C's BOOL. We include
44
// x86_64 here as well because the iOS simulator also uses _Bool.
5-
#if ((os(iOS) || os(tvOS)) && (arch(arm64) || arch(x86_64))) || os(watchOS)
65
public struct ObjCBool {
7-
private var value : Bool
6+
#if (os(macOS) && arch(x86_64)) || (os(iOS) && (arch(i386) || arch(arm) || targetEnvironment(macCatalyst)))
7+
8+
// On macOS and 32-bit iOS, Objective-C's BOOL type is a "signed char".
9+
private var value: UInt8
810

911
public init(_ value: Bool) {
10-
self.value = value
12+
self.value = value ? 1 : 0
1113
}
1214

15+
/// Allow use in a Boolean context.
1316
public var boolValue: Bool {
14-
return value
17+
return value != 0
1518
}
16-
}
17-
1819
#else
19-
20-
public struct ObjCBool {
21-
private var value : UInt8
20+
// Everywhere else it is C/C++'s "Bool"
21+
private var value: Bool
2222

2323
public init(_ value: Bool) {
24-
self.value = value ? 1 : 0
25-
}
26-
27-
public init(_ value: UInt8) {
2824
self.value = value
2925
}
3026

3127
public var boolValue: Bool {
32-
if value == 0 { return false }
33-
return true
28+
return value
3429
}
35-
}
3630
#endif
31+
}
3732

3833
extension ObjCBool : ExpressibleByBooleanLiteral {
3934
public init(booleanLiteral: Bool) {

test/TBD/app-extension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// EXTENSIONSAFE-NOT: not_app_extension_safe
1010
// NOTEXTENSIONSAFE: not_app_extension_safe
1111

12-
// RUN: %target-swift-frontend -target-variant x86_64-apple-ios13.0-macabi -typecheck %s -application-extension -emit-tbd -emit-tbd-path %t/target-variant.tbd
12+
// RUN: %target-swift-frontend -target-variant %target-cpu-apple-ios13.0-macabi -typecheck %s -application-extension -emit-tbd -emit-tbd-path %t/target-variant.tbd
1313
// RUN: %FileCheck %s --check-prefix MACABI < %t/target-variant.tbd
1414

1515
// MACABI: targets: [ {{.*}}macos{{.*}}maccatalyst{{.*}} ]

0 commit comments

Comments
 (0)