Skip to content

Commit 4d705ab

Browse files
authored
Merge pull request #32319 from meg-gupta/onfastpath
Ignore onFastPath builtin while looking for valid static initializer of a global variable
2 parents e2a20ab + 632b5ce commit 4d705ab

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

lib/SIL/IR/SILGlobalVariable.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ bool SILGlobalVariable::isValidStaticInitializerInst(const SILInstruction *I,
136136
auto *TE = bi->getSingleUserOfType<TupleExtractInst>();
137137
return TE && getOffsetSubtract(TE, M);
138138
}
139+
case BuiltinValueKind::OnFastPath:
140+
return true;
139141
default:
140142
break;
141143
}

test/SILOptimizer/optionset.swift

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ public struct TestOptions: OptionSet {
1212
static let fourth = TestOptions(rawValue: 1 << 3)
1313
}
1414

15-
// CHECK: sil @{{.*}}returnTestOptions{{.*}}
15+
// CHECK-LABEL: sil_global hidden [let] @$s4test17globalTestOptionsAA0cD0Vvp : $TestOptions = {
16+
// CHECK: [[CONST:%.*]] = integer_literal $Builtin.Int{{32|64}}, 15
17+
// CHECK: [[INT:%.*]] = struct $Int (%0 : $Builtin.Int{{32|64}})
18+
// CHECK: %initval = struct $TestOptions ([[INT]] : $Int)
19+
let globalTestOptions: TestOptions = [.first, .second, .third, .fourth]
20+
21+
// CHECK-LABEL: sil @{{.*}}returnTestOptions{{.*}}
1622
// CHECK-NEXT: bb0:
1723
// CHECK-NEXT: builtin
1824
// CHECK-NEXT: integer_literal {{.*}}, 15
@@ -23,24 +29,13 @@ public func returnTestOptions() -> TestOptions {
2329
return [.first, .second, .third, .fourth]
2430
}
2531

26-
// CHECK: sil @{{.*}}returnEmptyTestOptions{{.*}}
27-
// CHECK: [[ZERO:%[0-9]+]] = integer_literal {{.*}}, 0
28-
// CHECK: [[ZEROINT:%[0-9]+]] = struct $Int ([[ZERO]]
29-
// CHECK: [[TO:%[0-9]+]] = struct $TestOptions ([[ZEROINT]]
30-
// CHECK: return [[TO]]
31-
// CHECK: } // end sil function {{.*}}returnEmptyTestOptions{{.*}}
32-
public func returnEmptyTestOptions() -> TestOptions {
33-
return []
34-
}
35-
36-
// CHECK: alloc_global @{{.*}}globalTestOptions{{.*}}
37-
// CHECK-NEXT: global_addr
38-
// CHECK-NEXT: builtin
39-
// CHECK-NEXT: integer_literal {{.*}}, 15
32+
// CHECK-LABEL: sil @{{.*}}returnEmptyTestOptions{{.*}}
33+
// CHECK-NEXT: bb0:
34+
// CHECK-NEXT: integer_literal {{.*}}, 0
35+
// CHECK-NEXT: builtin "onFastPath"() : $()
4036
// CHECK-NEXT: struct $Int
4137
// CHECK-NEXT: struct $TestOptions
42-
// CHECK-NEXT: store
43-
// CHECK-NEXT: tuple
4438
// CHECK-NEXT: return
45-
let globalTestOptions: TestOptions = [.first, .second, .third, .fourth]
46-
39+
public func returnEmptyTestOptions() -> TestOptions {
40+
return []
41+
}

0 commit comments

Comments
 (0)