Skip to content

Commit 7aac3a9

Browse files
committed
[CFG] Replace hardcoded max BBs explored as CL option. NFC.
This option was hardcoded to 32. Changing this as a CL option since we have seen some cases downstream where increasing this limit allows us to disprove reachability. Reviewed-By: jdoerfert Differential Revision: https://reviews.llvm.org/D90487
1 parent ac49500 commit 7aac3a9

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

llvm/lib/Analysis/CFG.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,18 @@
1414
#include "llvm/Analysis/CFG.h"
1515
#include "llvm/Analysis/LoopInfo.h"
1616
#include "llvm/IR/Dominators.h"
17+
#include "llvm/Support/CommandLine.h"
1718

1819
using namespace llvm;
1920

21+
// The max number of basic blocks explored during reachability analysis between
22+
// two basic blocks. This is kept reasonably small to limit compile time when
23+
// repeatedly used by clients of this analysis (such as captureTracking).
24+
static cl::opt<unsigned> DefaultMaxBBsToExplore(
25+
"dom-tree-reachability-max-bbs-to-explore", cl::Hidden,
26+
cl::desc("Max number of BBs to explore for reachability analysis"),
27+
cl::init(32));
28+
2029
/// FindFunctionBackedges - Analyze the specified function to find all of the
2130
/// loop backedges in the function and return them. This is a relatively cheap
2231
/// (compared to computing dominators and loop info) analysis.
@@ -152,9 +161,7 @@ bool llvm::isPotentiallyReachableFromMany(
152161

153162
const Loop *StopLoop = LI ? getOutermostLoop(LI, StopBB) : nullptr;
154163

155-
// Limit the number of blocks we visit. The goal is to avoid run-away compile
156-
// times on large CFGs without hampering sensible code. Arbitrarily chosen.
157-
unsigned Limit = 32;
164+
unsigned Limit = DefaultMaxBBsToExplore;
158165
SmallPtrSet<const BasicBlock*, 32> Visited;
159166
do {
160167
BasicBlock *BB = Worklist.pop_back_val();

0 commit comments

Comments
 (0)