Skip to content

Commit 0a10d29

Browse files
committed
[5.0] Temporarily disable generation of static long Strings for macos.
There is a problem with the generated relocation, which has to be resolved before we can enable this optimization again. rdar://problem/47467102
1 parent 646034c commit 0a10d29

File tree

3 files changed

+64
-61
lines changed

3 files changed

+64
-61
lines changed

lib/SIL/SILGlobalVariable.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ bool SILGlobalVariable::isValidStaticInitializerInst(const SILInstruction *I,
119119
// a pointer+offset relocation.
120120
// Note that StringObjectOr requires the or'd bits in the first
121121
// operand to be 0, so the operation is equivalent to an addition.
122+
123+
// Temporarily disable static long Strings for macos.
124+
// rdar://problem/47467102
125+
if (M.getASTContext().LangOpts.Target.isMacOSX())
126+
return false;
127+
122128
if (isa<IntegerLiteralInst>(bi->getArguments()[1]))
123129
return true;
124130
break;

test/IRGen/static_initializer.sil

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -103,25 +103,6 @@ sil_global @static_array_with_empty_element : $TestArrayStorage = {
103103
}
104104
// CHECK: @static_array_with_empty_element = {{( dllexport)?}}{{(protected )?}}global %T18static_initializer16TestArrayStorageC_tailelems3c { [1 x i64] zeroinitializer, %T18static_initializer16TestArrayStorageC_tailelems3 <{ %swift.refcounted zeroinitializer, %Ts5Int32V <{ i32 2 }>, [1 x i8] undef, [1 x i8] undef }> }, align 8
105105

106-
struct MyString {
107-
var buffer: Builtin.BridgeObject
108-
}
109-
110-
sil_global [let] @string_with_offset : $MyString = {
111-
%0 = integer_literal $Builtin.Int64, -9223372036854775808
112-
%1 = integer_literal $Builtin.Int1, 0
113-
%2 = integer_literal $Builtin.Int64, 32
114-
%3 = string_literal utf8 "abc123asd3sdj3basfasdf"
115-
%4 = builtin "ptrtoint_Word"(%3 : $Builtin.RawPointer) : $Builtin.Word
116-
%5 = builtin "zextOrBitCast_Word_Int64"(%4 : $Builtin.Word) : $Builtin.Int64
117-
%6 = builtin "usub_with_overflow_Int64"(%5 : $Builtin.Int64, %2 : $Builtin.Int64, %1 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1)
118-
%7 = tuple_extract %6 : $(Builtin.Int64, Builtin.Int1), 0
119-
%8 = builtin "stringObjectOr_Int64"(%7 : $Builtin.Int64, %0 : $Builtin.Int64) : $Builtin.Int64
120-
%9 = value_to_bridge_object %8 : $Builtin.Int64
121-
%initval = struct $MyString (%9 : $Builtin.BridgeObject)
122-
}
123-
// CHECK: @string_with_offset = {{.*global .*}} <{ %swift.bridge* inttoptr (i64 add (i64 ptrtoint ([23 x i8]* @0 to i64), i64 9223372036854775776) to %swift.bridge*) }>, align 8
124-
125106
// CHECK-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc i8* @_TF2cha1xSi() {{.*}} {
126107
// CHECK-NEXT: entry:
127108
// CHECK-NEXT: ret i8* bitcast (%Ts5Int32V* @"$s2ch1xSiv" to i8*)

test/SILOptimizer/static_strings.swift

Lines changed: 58 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %target-swift-frontend -O -emit-ir %s | %FileCheck %s
2-
// RUN: %target-swift-frontend -Osize -emit-ir %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -O -emit-ir %s | %FileCheck --check-prefix=CHECK-%target-cpu %s
2+
// RUN: %target-swift-frontend -Osize -emit-ir %s | %FileCheck --check-prefix=CHECK-%target-cpu %s
33

44
// RUN: %empty-directory(%t)
55
// RUN: %target-build-swift -O -module-name=test %s -o %t/a.out
@@ -12,72 +12,88 @@
1212
// optimal code for static String variables.
1313

1414
public struct S {
15-
// CHECK: {{^@"}}[[SMALL:.*smallstr.*pZ]]" ={{.*}} global {{.*}} inttoptr
15+
// CHECK-x86_64: {{^@"}}[[SMALL:.*smallstr.*pZ]]" ={{.*}} global {{.*}} inttoptr
16+
// CHECK-arm64: {{^@"}}[[SMALL:.*smallstr.*pZ]]" ={{.*}} global {{.*}} inttoptr
1617
public static let smallstr = "abc123a"
17-
// CHECK: {{^@"}}[[LARGE:.*largestr.*pZ]]" ={{.*}} global {{.*}} inttoptr {{.*}} add
18+
// CHECK-arm64: {{^@"}}[[LARGE:.*largestr.*pZ]]" ={{.*}} global {{.*}} inttoptr {{.*}} add
1819
public static let largestr = "abc123asd3sdj3basfasdf"
19-
// CHECK: {{^@"}}[[UNICODE:.*unicodestr.*pZ]]" ={{.*}} global {{.*}} inttoptr {{.*}} add
20+
// CHECK-arm64: {{^@"}}[[UNICODE:.*unicodestr.*pZ]]" ={{.*}} global {{.*}} inttoptr {{.*}} add
2021
public static let unicodestr = "❄️gastroperiodyni"
2122
}
2223

2324
// unsafeMutableAddressor for S.smallstr
24-
// CHECK: define {{.*smallstr.*}}u"
25-
// CHECK-NEXT: entry:
26-
// CHECK-NEXT: ret {{.*}} @"[[SMALL]]"
27-
// CHECK-NEXT: }
25+
// CHECK-arm64: define {{.*smallstr.*}}u"
26+
// CHECK-arm64-NEXT: entry:
27+
// CHECK-arm64-NEXT: ret {{.*}} @"[[SMALL]]"
28+
// CHECK-arm64-NEXT: }
29+
30+
// CHECK-x86_64: define {{.*smallstr.*}}u"
31+
// CHECK-x86_64-NEXT: entry:
32+
// CHECK-x86_64-NEXT: ret {{.*}} @"[[SMALL]]"
33+
// CHECK-x86_64-NEXT: }
2834

2935
// getter for S.smallstr
30-
// CHECK: define {{.*smallstr.*}}gZ"
31-
// CHECK-NEXT: entry:
32-
// CHECK-NEXT: ret {{.*}}
33-
// CHECK-NEXT: }
36+
// CHECK-arm64: define {{.*smallstr.*}}gZ"
37+
// CHECK-arm64-NEXT: entry:
38+
// CHECK-arm64-NEXT: ret {{.*}}
39+
// CHECK-arm64-NEXT: }
40+
41+
// CHECK-x86_64: define {{.*smallstr.*}}gZ"
42+
// CHECK-x86_64-NEXT: entry:
43+
// CHECK-x86_64-NEXT: ret {{.*}}
44+
// CHECK-x86_64-NEXT: }
3445

3546
// unsafeMutableAddressor for S.largestr
36-
// CHECK: define {{.*largestr.*}}u"
37-
// CHECK-NEXT: entry:
38-
// CHECK-NEXT: ret {{.*}} @"[[LARGE]]"
39-
// CHECK-NEXT: }
47+
// CHECK-arm64: define {{.*largestr.*}}u"
48+
// CHECK-arm64-NEXT: entry:
49+
// CHECK-arm64-NEXT: ret {{.*}} @"[[LARGE]]"
50+
// CHECK-arm64-NEXT: }
4051

4152
// getter for S.largestr
42-
// CHECK: define {{.*largestr.*}}gZ"
43-
// CHECK-NEXT: entry:
44-
// CHECK-NEXT: ret {{.*}}
45-
// CHECK-NEXT: }
53+
// CHECK-arm64: define {{.*largestr.*}}gZ"
54+
// CHECK-arm64-NEXT: entry:
55+
// CHECK-arm64-NEXT: ret {{.*}}
56+
// CHECK-arm64-NEXT: }
4657

4758
// unsafeMutableAddressor for S.unicodestr
48-
// CHECK: define {{.*unicodestr.*}}u"
49-
// CHECK-NEXT: entry:
50-
// CHECK-NEXT: ret {{.*}} @"[[UNICODE]]"
51-
// CHECK-NEXT: }
59+
// CHECK-arm64: define {{.*unicodestr.*}}u"
60+
// CHECK-arm64-NEXT: entry:
61+
// CHECK-arm64-NEXT: ret {{.*}} @"[[UNICODE]]"
62+
// CHECK-arm64-NEXT: }
5263

5364
// getter for S.unicodestr
54-
// CHECK: define {{.*unicodestr.*}}gZ"
55-
// CHECK-NEXT: entry:
56-
// CHECK-NEXT: ret {{.*}}
57-
// CHECK-NEXT: }
58-
59-
// CHECK-LABEL: define {{.*}}get_smallstr
60-
// CHECK: entry:
61-
// CHECK-NEXT: ret {{.*}}
62-
// CHECK-NEXT: }
65+
// CHECK-arm64: define {{.*unicodestr.*}}gZ"
66+
// CHECK-arm64-NEXT: entry:
67+
// CHECK-arm64-NEXT: ret {{.*}}
68+
// CHECK-arm64-NEXT: }
69+
70+
// CHECK-arm64-LABEL: define {{.*}}get_smallstr
71+
// CHECK-arm64: entry:
72+
// CHECK-arm64-NEXT: ret {{.*}}
73+
// CHECK-arm64-NEXT: }
74+
75+
// CHECK-x86_64-LABEL: define {{.*}}get_smallstr
76+
// CHECK-x86_64: entry:
77+
// CHECK-x86_64-NEXT: ret {{.*}}
78+
// CHECK-x86_64-NEXT: }
6379
@inline(never)
6480
public func get_smallstr() -> String {
6581
return S.smallstr
6682
}
6783

68-
// CHECK-LABEL: define {{.*}}get_largestr
69-
// CHECK: entry:
70-
// CHECK-NEXT: ret {{.*}}
71-
// CHECK-NEXT: }
84+
// CHECK-arm64-LABEL: define {{.*}}get_largestr
85+
// CHECK-arm64: entry:
86+
// CHECK-arm64-NEXT: ret {{.*}}
87+
// CHECK-arm64-NEXT: }
7288
@inline(never)
7389
public func get_largestr() -> String {
7490
return S.largestr
7591
}
7692

77-
// CHECK-LABEL: define {{.*}}get_unicodestr
78-
// CHECK: entry:
79-
// CHECK-NEXT: ret {{.*}}
80-
// CHECK-NEXT: }
93+
// CHECK-arm64-LABEL: define {{.*}}get_unicodestr
94+
// CHECK-arm64: entry:
95+
// CHECK-arm64-NEXT: ret {{.*}}
96+
// CHECK-arm64-NEXT: }
8197
@inline(never)
8298
public func get_unicodestr() -> String {
8399
return S.unicodestr

0 commit comments

Comments
 (0)