@@ -322,7 +322,7 @@ void swift::executePassPipelinePlan(SILModule *SM,
322322SILPassManager::SILPassManager (SILModule *M, bool isMandatory,
323323 irgen::IRGenModule *IRMod)
324324 : Mod(M), IRMod(IRMod),
325- libswiftPassInvocation (this ),
325+ swiftPassInvocation (this ),
326326 isMandatory(isMandatory), deserializationNotificationHandler(nullptr ) {
327327#define ANALYSIS (NAME ) \
328328 Analyses.push_back (create##NAME##Analysis (Mod));
@@ -469,7 +469,7 @@ void SILPassManager::runPassOnFunction(unsigned TransIdx, SILFunction *F) {
469469 assert (changeNotifications == SILAnalysis::InvalidationKind::Nothing
470470 && " change notifications not cleared" );
471471
472- libswiftPassInvocation. startPassRun (F);
472+ swiftPassInvocation. startFunctionPassRun (F);
473473
474474 // Run it!
475475 SFT->run ();
@@ -478,7 +478,7 @@ void SILPassManager::runPassOnFunction(unsigned TransIdx, SILFunction *F) {
478478 invalidateAnalysis (F, changeNotifications);
479479 changeNotifications = SILAnalysis::InvalidationKind::Nothing;
480480 }
481- libswiftPassInvocation. finishedPassRun ();
481+ swiftPassInvocation. finishedFunctionPassRun ();
482482
483483 if (SILForceVerifyAll ||
484484 SILForceVerifyAroundPass.end () !=
@@ -1078,13 +1078,13 @@ void SILPassManager::viewCallGraph() {
10781078}
10791079
10801080// ===----------------------------------------------------------------------===//
1081- // LibswiftPassInvocation
1081+ // SwiftPassInvocation
10821082// ===----------------------------------------------------------------------===//
10831083
10841084static_assert (BridgedSlabCapacity == FixedSizeSlab::capacity,
10851085 " wrong bridged slab capacity" );
10861086
1087- FixedSizeSlab *LibswiftPassInvocation ::allocSlab (FixedSizeSlab *afterSlab) {
1087+ FixedSizeSlab *SwiftPassInvocation ::allocSlab (FixedSizeSlab *afterSlab) {
10881088 FixedSizeSlab *slab = passManager->getModule ()->allocSlab ();
10891089 if (afterSlab) {
10901090 allocatedSlabs.insert (std::next (afterSlab->getIterator ()), *slab);
@@ -1094,7 +1094,7 @@ FixedSizeSlab *LibswiftPassInvocation::allocSlab(FixedSizeSlab *afterSlab) {
10941094 return slab;
10951095}
10961096
1097- FixedSizeSlab *LibswiftPassInvocation ::freeSlab (FixedSizeSlab *slab) {
1097+ FixedSizeSlab *SwiftPassInvocation ::freeSlab (FixedSizeSlab *slab) {
10981098 FixedSizeSlab *prev = nullptr ;
10991099 assert (!allocatedSlabs.empty ());
11001100 if (&allocatedSlabs.front () != slab)
@@ -1105,23 +1105,37 @@ FixedSizeSlab *LibswiftPassInvocation::freeSlab(FixedSizeSlab *slab) {
11051105 return prev;
11061106}
11071107
1108- void LibswiftPassInvocation::startPassRun (SILFunction *function) {
1108+ void SwiftPassInvocation::startFunctionPassRun (SILFunction *function) {
11091109 assert (!this ->function && " a pass is already running" );
11101110 this ->function = function;
11111111}
11121112
1113- void LibswiftPassInvocation::finishedPassRun () {
1114- assert (allocatedSlabs.empty () && " StackList is leaking slabs" );
1113+ void SwiftPassInvocation::startInstructionPassRun (SILInstruction *inst) {
1114+ assert (inst->getFunction () == function &&
1115+ " running instruction pass on wrong function" );
1116+ }
1117+
1118+ void SwiftPassInvocation::finishedFunctionPassRun () {
1119+ endPassRunChecks ();
1120+ assert (function && " not running a pass" );
11151121 function = nullptr ;
11161122}
11171123
1124+ void SwiftPassInvocation::finishedInstructionPassRun () {
1125+ endPassRunChecks ();
1126+ }
1127+
1128+ void SwiftPassInvocation::endPassRunChecks () {
1129+ assert (allocatedSlabs.empty () && " StackList is leaking slabs" );
1130+ }
1131+
11181132// ===----------------------------------------------------------------------===//
11191133// Swift Bridging
11201134// ===----------------------------------------------------------------------===//
11211135
1122- inline LibswiftPassInvocation *castToPassInvocation (BridgedPassContext ctxt) {
1123- return const_cast <LibswiftPassInvocation *>(
1124- static_cast <const LibswiftPassInvocation *>(ctxt.opaqueCtxt ));
1136+ inline SwiftPassInvocation *castToPassInvocation (BridgedPassContext ctxt) {
1137+ return const_cast <SwiftPassInvocation *>(
1138+ static_cast <const SwiftPassInvocation *>(ctxt.opaqueCtxt ));
11251139}
11261140
11271141inline FixedSizeSlab *castToSlab (BridgedSlab slab) {
@@ -1158,7 +1172,7 @@ BridgedSlab PassContext_freeSlab(BridgedPassContext passContext,
11581172
11591173void PassContext_notifyChanges (BridgedPassContext passContext,
11601174 enum ChangeNotificationKind changeKind) {
1161- LibswiftPassInvocation *inv = castToPassInvocation (passContext);
1175+ SwiftPassInvocation *inv = castToPassInvocation (passContext);
11621176 switch (changeKind) {
11631177 case instructionsChanged:
11641178 inv->notifyChanges (SILAnalysis::InvalidationKind::Instructions);
@@ -1185,7 +1199,7 @@ SwiftInt PassContext_isSwift51RuntimeAvailable(BridgedPassContext context) {
11851199}
11861200
11871201BridgedAliasAnalysis PassContext_getAliasAnalysis (BridgedPassContext context) {
1188- LibswiftPassInvocation *invocation = castToPassInvocation (context);
1202+ SwiftPassInvocation *invocation = castToPassInvocation (context);
11891203 SILPassManager *pm = invocation->getPassManager ();
11901204 return {pm->getAnalysis <AliasAnalysis>(invocation->getFunction ())};
11911205}
0 commit comments