Skip to content

Commit b90aee7

Browse files
Fix review
1 parent f263f08 commit b90aee7

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/passes/CodeFolding.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,6 @@ struct CodeFolding
136136
modifieds; // modified code should not be processed
137137
// again, wait for next pass
138138

139-
// Cache of expressions that have branches exiting to targets defined
140-
// outside them. Populated lazily on first access via PostWalker.
141-
std::unordered_set<Expression*> exitingBranchCache_;
142-
bool exitingBranchCachePopulated_ = false;
143-
144139
// walking
145140

146141
void visitExpression(Expression* curr) {
@@ -305,28 +300,30 @@ struct CodeFolding
305300
returnTails.clear();
306301
unoptimizables.clear();
307302
modifieds.clear();
308-
exitingBranchCache_.clear();
309-
exitingBranchCachePopulated_ = false;
303+
exitingBranchCache.clear();
304+
exitingBranchCachePopulated = false;
310305
if (needEHFixups) {
311306
EHUtils::handleBlockNestedPops(func, *getModule());
312307
}
313308
}
314309
}
315310

316311
private:
317-
// Check if an expression has branches that exit to targets defined outside
318-
// it. The cache is populated lazily on first call using a PostWalker for
319-
// efficient bottom-up traversal.
312+
// Cache of expressions that have branches exiting to targets defined
313+
// outside them. Populated lazily on first access via hasExitingBranches().
314+
std::unordered_set<Expression*> exitingBranchCache;
315+
bool exitingBranchCachePopulated = false;
316+
320317
bool hasExitingBranches(Expression* expr) {
321-
if (!exitingBranchCachePopulated_) {
318+
if (!exitingBranchCachePopulated) {
322319
populateExitingBranchCache(getFunction()->body);
323-
exitingBranchCachePopulated_ = true;
320+
exitingBranchCachePopulated = true;
324321
}
325-
return exitingBranchCache_.count(expr);
322+
return exitingBranchCache.count(expr);
326323
}
327324

328325
// Pre-populate the exiting branch cache for all sub-expressions of root
329-
// in a single O(N) bottom-up walk. After this, exitingBranchCache_
326+
// in a single O(N) bottom-up walk. After this, exitingBranchCache
330327
// lookups are O(1).
331328
void populateExitingBranchCache(Expression* root) {
332329
struct CachePopulator
@@ -371,7 +368,7 @@ struct CodeFolding
371368
}
372369
}
373370
};
374-
CachePopulator populator(exitingBranchCache_);
371+
CachePopulator populator(exitingBranchCache);
375372
populator.walk(root);
376373
}
377374

0 commit comments

Comments
 (0)