Skip to content

Commit e152b2c

Browse files
committed
Swift Optimizer: add the fixStackNesting utility in PassContext
This bridges to the StackNesting utility in C++
1 parent a24b17a commit e152b2c

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

SwiftCompilerSources/Sources/Optimizer/PassManager/PassUtils.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ struct PassContext {
111111

112112
RefCountingInst_setIsAtomic(instruction.bridged, isAtomic)
113113
}
114+
115+
func fixStackNesting(function: Function) {
116+
PassContext_fixStackNesting(_bridged, function.bridged)
117+
}
114118
}
115119

116120
struct FunctionPass {

include/swift/SILOptimizer/OptimizerBridging.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ BridgedSlab PassContext_allocSlab(BridgedPassContext passContext,
119119
BridgedSlab PassContext_freeSlab(BridgedPassContext passContext,
120120
BridgedSlab slab);
121121

122+
void PassContext_fixStackNesting(BridgedPassContext context,
123+
BridgedFunction function);
124+
122125
BridgedBasicBlockSet PassContext_allocBasicBlockSet(BridgedPassContext context);
123126
void PassContext_freeBasicBlockSet(BridgedPassContext context,
124127
BridgedBasicBlockSet set);

lib/SILOptimizer/PassManager/PassManager.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "swift/SILOptimizer/PassManager/PrettyStackTrace.h"
2929
#include "swift/SILOptimizer/PassManager/Transforms.h"
3030
#include "swift/SILOptimizer/Utils/OptimizerStatsUtils.h"
31+
#include "swift/SILOptimizer/Utils/StackNesting.h"
3132
#include "llvm/ADT/DenseMap.h"
3233
#include "llvm/ADT/Statistic.h"
3334
#include "llvm/ADT/StringSwitch.h"
@@ -1225,6 +1226,20 @@ void PassContext_eraseInstruction(BridgedPassContext passContext,
12251226
castToPassInvocation(passContext)->eraseInstruction(castToInst(inst));
12261227
}
12271228

1229+
void PassContext_fixStackNesting(BridgedPassContext passContext,
1230+
BridgedFunction function) {
1231+
switch (StackNesting::fixNesting(castToFunction(function))) {
1232+
case StackNesting::Changes::None:
1233+
break;
1234+
case StackNesting::Changes::Instructions:
1235+
PassContext_notifyChanges(passContext, instructionsChanged);
1236+
break;
1237+
case StackNesting::Changes::CFG:
1238+
PassContext_notifyChanges(passContext, branchesChanged);
1239+
break;
1240+
}
1241+
}
1242+
12281243
SwiftInt PassContext_isSwift51RuntimeAvailable(BridgedPassContext context) {
12291244
SILPassManager *pm = castToPassInvocation(context)->getPassManager();
12301245
ASTContext &ctxt = pm->getModule()->getASTContext();

0 commit comments

Comments
 (0)