Skip to content

Commit 6afc48f

Browse files
committed
Update DT only when we get different functions
Change-Id: I296a55dba127c1ae74cca9e0edcb10f2f44640e9
1 parent 48cbe62 commit 6afc48f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

llvm/lib/Analysis/InlineCost.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
263263
// Cache the DataLayout since we use it a lot.
264264
const DataLayout &DL;
265265

266+
DominatorTree DT;
267+
266268
/// The OptimizationRemarkEmitter available for this compilation.
267269
OptimizationRemarkEmitter *ORE;
268270

@@ -1726,7 +1728,14 @@ bool CallAnalyzer::simplifyCmpInst(Function *F, CmpInst &Cmp) {
17261728
DomConditionCache DC;
17271729
DC.registerBranch(Br);
17281730
SQ.DC = &DC;
1729-
DominatorTree DT(*F);
1731+
if (DT.root_size() == 0) {
1732+
// Dominator tree was never constructed for any function yet.
1733+
DT.recalculate(*F);
1734+
} else if (DT.getRoot()->getParent() != F) {
1735+
// Dominator tree was constructed for a different function, recalculate
1736+
// it for the current function.
1737+
DT.recalculate(*F);
1738+
}
17301739
SQ.DT = &DT;
17311740
Value *simplifiedInstruction = llvm::simplifyInstructionWithOperands(
17321741
CmpInstr, {CallArg, Cmp.getOperand(1)}, SQ);

0 commit comments

Comments
 (0)