File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff 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);
You can’t perform that action at this time.
0 commit comments