Skip to content

Commit 59ad8b6

Browse files
committed
Optimizer: add var Context.currentModuleContext
1 parent 1ce545b commit 59ad8b6

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

SwiftCompilerSources/Sources/Optimizer/PassManager/Context.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ extension Context {
4444
}
4545
}
4646

47+
var currentModuleContext: ModuleDecl {
48+
_bridged.getCurrentModuleContext().getAs(ModuleDecl.self)
49+
}
50+
4751
var moduleIsSerialized: Bool { _bridged.moduleIsSerialized() }
4852

4953
/// Enable diagnostics requiring WMO (for @noLocks, @noAllocation

include/swift/SILOptimizer/OptimizerBridging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ struct BridgedPassContext {
382382
BRIDGED_INLINE bool enableMoveInoutStackProtection() const;
383383
BRIDGED_INLINE AssertConfiguration getAssertConfiguration() const;
384384
bool enableSimplificationFor(BridgedInstruction inst) const;
385+
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclObj getCurrentModuleContext() const;
385386
BRIDGED_INLINE bool enableWMORequiredDiagnostics() const;
386387

387388
// Temporary for AddressableParameters Bootstrapping.

include/swift/SILOptimizer/OptimizerBridgingImpl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,10 @@ bool BridgedPassContext::shouldExpand(BridgedType ty) const {
578578
return swift::shouldExpand(mod, ty.unbridged());
579579
}
580580

581+
BridgedDeclObj BridgedPassContext::getCurrentModuleContext() const {
582+
return {invocation->getPassManager()->getModule()->getSwiftModule()};
583+
}
584+
581585
bool BridgedPassContext::enableWMORequiredDiagnostics() const {
582586
swift::SILModule *mod = invocation->getPassManager()->getModule();
583587
return mod->getOptions().EnableWMORequiredDiagnostics;

0 commit comments

Comments
 (0)