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> {
263
263
// Cache the DataLayout since we use it a lot.
264
264
const DataLayout &DL;
265
265
266
+ DominatorTree DT;
267
+
266
268
// / The OptimizationRemarkEmitter available for this compilation.
267
269
OptimizationRemarkEmitter *ORE;
268
270
@@ -1726,7 +1728,14 @@ bool CallAnalyzer::simplifyCmpInst(Function *F, CmpInst &Cmp) {
1726
1728
DomConditionCache DC;
1727
1729
DC.registerBranch (Br);
1728
1730
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
+ }
1730
1739
SQ.DT = &DT;
1731
1740
Value *simplifiedInstruction = llvm::simplifyInstructionWithOperands (
1732
1741
CmpInstr, {CallArg, Cmp.getOperand (1 )}, SQ);
You can’t perform that action at this time.
0 commit comments