Skip to content

Commit f0f1c3c

Browse files
committed
SIL: make SILFunctionConvention constructible without needing a SIL function
Add an initializer which takes the `hasLoweredAddresses` directly and add `Context.moduleHasLoweredAddresses`
1 parent d1f581b commit f0f1c3c

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

SwiftCompilerSources/Sources/Optimizer/PassManager/Context.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ extension Context {
5050

5151
var moduleIsSerialized: Bool { _bridged.moduleIsSerialized() }
5252

53+
var moduleHasLoweredAddresses: Bool { _bridged.moduleHasLoweredAddresses() }
54+
5355
/// Enable diagnostics requiring WMO (for @noLocks, @noAllocation
5456
/// annotations, Embedded Swift, and class specialization). SourceKit is the
5557
/// only consumer that has this disabled today (as it disables WMO

SwiftCompilerSources/Sources/SIL/FunctionConvention.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ public struct FunctionConvention : CustomStringConvertible {
2626
let functionType: CanonicalType
2727
let hasLoweredAddresses: Bool
2828

29-
init(for functionType: CanonicalType, in function: Function) {
29+
public init(for functionType: CanonicalType, in function: Function) {
30+
self.init(for: functionType, hasLoweredAddresses: function.hasLoweredAddresses)
31+
}
32+
33+
public init(for functionType: CanonicalType, hasLoweredAddresses: Bool) {
3034
assert(!functionType.hasTypeParameter, "requires contextual type")
3135
self.functionType = functionType
32-
self.hasLoweredAddresses = function.hasLoweredAddresses
36+
self.hasLoweredAddresses = hasLoweredAddresses
3337
}
3438

3539
/// All results including the error.
@@ -209,7 +213,7 @@ public struct ParameterInfo : CustomStringConvertible {
209213
}
210214

211215
extension FunctionConvention {
212-
public struct Parameters : Collection {
216+
public struct Parameters : RandomAccessCollection {
213217
let bridged: BridgedParameterInfoArray
214218
let hasLoweredAddresses: Bool
215219

include/swift/SILOptimizer/OptimizerBridging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ struct BridgedPassContext {
205205
BRIDGED_INLINE SILStage getSILStage() const;
206206
BRIDGED_INLINE bool hadError() const;
207207
BRIDGED_INLINE bool moduleIsSerialized() const;
208+
BRIDGED_INLINE bool moduleHasLoweredAddresses() const;
208209
BRIDGED_INLINE bool isTransforming(BridgedFunction function) const;
209210

210211
// Analysis

include/swift/SILOptimizer/OptimizerBridgingImpl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ bool BridgedPassContext::moduleIsSerialized() const {
183183
return invocation->getPassManager()->getModule()->isSerialized();
184184
}
185185

186+
bool BridgedPassContext::moduleHasLoweredAddresses() const {
187+
return invocation->getPassManager()->getModule()->useLoweredAddresses();
188+
}
189+
186190
bool BridgedPassContext::isTransforming(BridgedFunction function) const {
187191
return invocation->getFunction() == function.getFunction();
188192
}

0 commit comments

Comments
 (0)