Skip to content

Commit 0990446

Browse files
committed
Update SDK mocks to have the correct definition of ObjCBool for TVOS sim
target. Update IRGen/abitypes.swift for TVOS x86_64, arm64 targets. <rdar://problem/20546299> Difference in ABI re ObjC bools between TVOS sim and iOS sim? Swift SVN r28575
1 parent b61754d commit 0990446

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

test/IRGen/abitypes.swift

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/abi %s -emit-ir | FileCheck -check-prefix=%target-cpu-%target-os %s
22

33
// FIXME: rdar://problem/19648117 Needs splitting objc parts out
4-
// UNSUPPORTED: OS=tvos
54
// XFAIL: linux
65

76
import gadget
@@ -14,6 +13,7 @@ import Foundation
1413
}
1514

1615
// arm64-ios: [[ARM64MYRECT:%.*]] = type { float, float, float, float }
16+
// arm64-tvos: [[ARM64MYRECT:%.*]] = type { float, float, float, float }
1717

1818
class Foo {
1919
// x86_64-macosx: define hidden void @_TFC8abitypes3Foo3barfS0_FT_VSC6MyRect(%VSC6MyRect* noalias sret, %C8abitypes3Foo*) {{.*}} {
@@ -26,6 +26,10 @@ class Foo {
2626
// armv7-ios: define hidden void @_TToFC8abitypes3Foo3barfS0_FT_VSC6MyRect(%VSC6MyRect* noalias sret, i8*, i8*) unnamed_addr {{.*}} {
2727
// arm64-ios: define hidden void @_TFC8abitypes3Foo3barfS0_FT_VSC6MyRect(%VSC6MyRect* noalias sret, %C8abitypes3Foo*) {{.*}} {
2828
// arm64-ios: define hidden [[ARM64MYRECT]] @_TToFC8abitypes3Foo3barfS0_FT_VSC6MyRect(i8*, i8*) unnamed_addr {{.*}} {
29+
// x86_64-tvos: define hidden void @_TFC8abitypes3Foo3barfS0_FT_VSC6MyRect(%VSC6MyRect* noalias sret, %C8abitypes3Foo*) {{.*}} {
30+
// x86_64-tvos: define hidden { <2 x float>, <2 x float> } @_TToFC8abitypes3Foo3barfS0_FT_VSC6MyRect(i8*, i8*) unnamed_addr {{.*}} {
31+
// arm64-tvos: define hidden void @_TFC8abitypes3Foo3barfS0_FT_VSC6MyRect(%VSC6MyRect* noalias sret, %C8abitypes3Foo*) {{.*}} {
32+
// arm64-tvos: define hidden [[ARM64MYRECT]] @_TToFC8abitypes3Foo3barfS0_FT_VSC6MyRect(i8*, i8*) unnamed_addr {{.*}} {
2933
dynamic func bar() -> MyRect {
3034
return MyRect(x: 1, y: 2, width: 3, height: 4)
3135
}
@@ -208,6 +212,18 @@ class Foo {
208212
// i386-ios-fixme: [[R2:%[0-9]+]] = call i1 @_TFC8abitypes3Foo6negate{{.*}}(i1 [[R1]]
209213
// i386-ios-fixme: [[R3:%[0-9]+]] = call i8 @_TF10ObjectiveC22_convertBoolToObjCBool{{.*}}(i1 [[R2]]
210214
// i386-ios-fixme: ret i8 [[R3]]
215+
//
216+
// x86_64-tvos-fixme: define hidden i1 @_TFC8abitypes3Foo6negatefS0_FTSb_Sb(i1, %C8abitypes3Foo*) {{.*}} {
217+
// x86_64-tvos-fixme: define internal zeroext i1 @_TToFC8abitypes3Foo6negatefS0_FT
218+
// x86_64-tvos-fixme: [[R1:%[0-9]+]] = call i1 @_TF10ObjectiveC22_convertObjCBoolToBoolFT1xVS_8ObjCBool_Sb(i1 %2)
219+
// x86_64-tvos-fixme: [[R2:%[0-9]+]] = call i1 @_TFC8abitypes3Foo6negatefS0_FTSb_Sb(i1 [[R1]]
220+
// x86_64-tvos-fixme: [[R3:%[0-9]+]] = call i1 @_TF10ObjectiveC22_convertBoolToObjCBoolFT1xSb_VS_8ObjCBool(i1 [[R2]])
221+
// x86_64-tvos-fixme: ret i1 [[R3]]
222+
//
223+
// arm64-tvos-fixme: define hidden i1 @_TFC8abitypes3Foo6negate{{.*}}(i1, %C8abitypes3Foo*) {{.*}} {
224+
// arm64-tvos-fixme: define internal zeroext i1 @_TToFC8abitypes3Foo6negate
225+
// arm64-tvos-fixme: [[R2:%[0-9]+]] = call i1 @_TFC8abitypes3Foo6negate
226+
// arm64-tvos-fixme: ret i1 [[R2]]
211227
dynamic func negate(b: Bool) -> Bool {
212228
return !b
213229
}
@@ -271,6 +287,26 @@ class Foo {
271287
// i386-ios: [[TOOBJCBOOL:%[0-9]+]] = call i8 @_TF10ObjectiveC22_convertBoolToObjCBool{{.*}}(i1 [[NEG]])
272288
// i386-ios: ret i8 [[TOOBJCBOOL]]
273289
//
290+
// x86_64-tvos: define hidden i1 @_TFC8abitypes3Foo7negate2{{.*}}(i1, %C8abitypes3Foo*) {{.*}} {
291+
// x86_64-tvos: [[SEL:%[0-9]+]] = load i8*, i8** @"\01L_selector(negate:)", align 8
292+
// x86_64-tvos: [[NEG:%[0-9]+]] = call zeroext i1 bitcast (void ()* @objc_msgSend to i1 ([[RECEIVER:.*]]*, i8*, i1)*)([[RECEIVER]]* {{%[0-9]+}}, i8* [[SEL]], i1 zeroext %0)
293+
// x86_64-tvos: ret i1 [[NEG]]
294+
//
295+
// x86_64-tvos: define hidden zeroext i1 @_TToFC8abitypes3Foo7negate2{{.*}}(i8*, i8*, i1 zeroext)
296+
// x86_64-tvos: [[NEG:%[0-9]+]] = call i1 @_TFC8abitypes3Foo7negate2{{.*}}(i1
297+
// x86_64-tvos: [[TOOBJCBOOL:%[0-9]+]] = call i1 @_TF10ObjectiveC22_convertBoolToObjCBool{{.*}}(i1 [[NEG]])
298+
// x86_64-tvos: ret i1 [[TOOBJCBOOL]]
299+
//
300+
// arm64-tvos: define hidden i1 @_TFC8abitypes3Foo7negate2{{.*}}(i1, %C8abitypes3Foo*) {{.*}} {
301+
// arm64-tvos: [[SEL:%[0-9]+]] = load i8*, i8** @"\01L_selector(negate:)", align 8
302+
// arm64-tvos: [[NEG:%[0-9]+]] = call zeroext i1 bitcast (void ()* @objc_msgSend to i1 ([[RECEIVER:.*]]*, i8*, i1)*)([[RECEIVER]]* {{%[0-9]+}}, i8* [[SEL]], i1 zeroext %0)
303+
// arm64-tvos: ret i1 [[NEG]]
304+
//
305+
// arm64-tvos: define hidden zeroext i1 @_TToFC8abitypes3Foo7negate2{{.*}}(i8*, i8*, i1 zeroext)
306+
// arm64-tvos: [[NEG:%[0-9]+]] = call i1 @_TFC8abitypes3Foo7negate2{{.*}}(i1
307+
// arm64-tvos: [[TOOBJCBOOL:%[0-9]+]] = call i1 @_TF10ObjectiveC22_convertBoolToObjCBool{{.*}}(i1 [[NEG]])
308+
// arm64-tvos: ret i1 [[TOOBJCBOOL]]
309+
//
274310
dynamic func negate2(b: Bool) -> Bool {
275311
var g = Gadget()
276312
return g.negate(b)
@@ -327,6 +363,9 @@ class Foo {
327363

328364
// arm64-ios: define hidden void @_TFC8abitypes3Foo14callJustReturn{{.*}}(%VSC9BigStruct* noalias sret, %CSo13StructReturns*, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, %C8abitypes3Foo*) {{.*}} {
329365
// arm64-ios: define hidden void @_TToFC8abitypes3Foo14callJustReturnfS0_FTCSo13StructReturns4withVSC9BigStruct_S2_(%VSC9BigStruct* noalias sret, i8*, i8*, [[OPAQUE:.*]]*, %VSC9BigStruct*) unnamed_addr {{.*}} {
366+
//
367+
// arm64-tvos: define hidden void @_TFC8abitypes3Foo14callJustReturn{{.*}}(%VSC9BigStruct* noalias sret, %CSo13StructReturns*, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, %C8abitypes3Foo*) {{.*}} {
368+
// arm64-tvos: define hidden void @_TToFC8abitypes3Foo14callJustReturnfS0_FTCSo13StructReturns4withVSC9BigStruct_S2_(%VSC9BigStruct* noalias sret, i8*, i8*, [[OPAQUE:.*]]*, %VSC9BigStruct*) unnamed_addr {{.*}} {
330369
dynamic func callJustReturn(r: StructReturns, with v: BigStruct) -> BigStruct {
331370
return r.justReturn(v)
332371
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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) && (arch(arm64) || arch(x86_64))
5+
#if (os(iOS) || os(tvOS)) && (arch(arm64) || arch(x86_64))
66
public struct ObjCBool : BooleanType {
77
private var value : Bool
88

test/Inputs/objc-generics-sdk/swift-modules/ObjectiveC.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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) && (arch(arm64) || arch(x86_64))
5+
#if (os(iOS) || os(tvOS)) && (arch(arm64) || arch(x86_64))
66
public struct ObjCBool : BooleanType {
77
private var value : Bool
88

0 commit comments

Comments
 (0)