Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/SIL/IR/SILGlobalVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ bool SILGlobalVariable::isValidStaticInitializerInst(const SILInstruction *I,
auto *TE = bi->getSingleUserOfType<TupleExtractInst>();
return TE && getOffsetSubtract(TE, M);
}
case BuiltinValueKind::OnFastPath:
return true;
default:
break;
}
Expand Down
33 changes: 14 additions & 19 deletions test/SILOptimizer/optionset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ public struct TestOptions: OptionSet {
static let fourth = TestOptions(rawValue: 1 << 3)
}

// CHECK: sil @{{.*}}returnTestOptions{{.*}}
// CHECK-LABEL: sil_global hidden [let] @$s4test17globalTestOptionsAA0cD0Vvp : $TestOptions = {
// CHECK: [[CONST:%.*]] = integer_literal $Builtin.Int{{32|64}}, 15
// CHECK: [[INT:%.*]] = struct $Int (%0 : $Builtin.Int{{32|64}})
// CHECK: %initval = struct $TestOptions ([[INT]] : $Int)
let globalTestOptions: TestOptions = [.first, .second, .third, .fourth]

// CHECK-LABEL: sil @{{.*}}returnTestOptions{{.*}}
// CHECK-NEXT: bb0:
// CHECK-NEXT: builtin
// CHECK-NEXT: integer_literal {{.*}}, 15
Expand All @@ -23,24 +29,13 @@ public func returnTestOptions() -> TestOptions {
return [.first, .second, .third, .fourth]
}

// CHECK: sil @{{.*}}returnEmptyTestOptions{{.*}}
// CHECK: [[ZERO:%[0-9]+]] = integer_literal {{.*}}, 0
// CHECK: [[ZEROINT:%[0-9]+]] = struct $Int ([[ZERO]]
// CHECK: [[TO:%[0-9]+]] = struct $TestOptions ([[ZEROINT]]
// CHECK: return [[TO]]
// CHECK: } // end sil function {{.*}}returnEmptyTestOptions{{.*}}
public func returnEmptyTestOptions() -> TestOptions {
return []
}

// CHECK: alloc_global @{{.*}}globalTestOptions{{.*}}
// CHECK-NEXT: global_addr
// CHECK-NEXT: builtin
// CHECK-NEXT: integer_literal {{.*}}, 15
// CHECK-LABEL: sil @{{.*}}returnEmptyTestOptions{{.*}}
// CHECK-NEXT: bb0:
// CHECK-NEXT: integer_literal {{.*}}, 0
// CHECK-NEXT: builtin "onFastPath"() : $()
// CHECK-NEXT: struct $Int
// CHECK-NEXT: struct $TestOptions
// CHECK-NEXT: store
// CHECK-NEXT: tuple
// CHECK-NEXT: return
let globalTestOptions: TestOptions = [.first, .second, .third, .fourth]

public func returnEmptyTestOptions() -> TestOptions {
return []
}