@@ -568,7 +568,8 @@ class PeepholeOptimizerLegacy : public MachineFunctionPass {
568
568
void getAnalysisUsage (AnalysisUsage &AU) const override {
569
569
MachineFunctionPass::getAnalysisUsage (AU);
570
570
AU.addRequired <MachineLoopInfoWrapperPass>();
571
- AU.addRequired <MachineDominatorTreeWrapperPass>();
571
+ if (Aggressive)
572
+ AU.addRequired <MachineDominatorTreeWrapperPass>();
572
573
}
573
574
574
575
MachineFunctionProperties getRequiredProperties () const override {
@@ -1645,7 +1646,8 @@ PreservedAnalyses
1645
1646
PeepholeOptimizerPass::run (MachineFunction &MF,
1646
1647
MachineFunctionAnalysisManager &MFAM) {
1647
1648
MFPropsModifier _ (*this , MF);
1648
- auto *DT = &MFAM.getResult <MachineDominatorTreeAnalysis>(MF);
1649
+ auto *DT =
1650
+ Aggressive ? &MFAM.getResult <MachineDominatorTreeAnalysis>(MF) : nullptr ;
1649
1651
auto *MLI = &MFAM.getResult <MachineLoopAnalysis>(MF);
1650
1652
PeepholeOptimizer Impl (DT, MLI);
1651
1653
bool Changed = Impl.run (MF);
@@ -1658,7 +1660,9 @@ PeepholeOptimizerPass::run(MachineFunction &MF,
1658
1660
bool PeepholeOptimizerLegacy::runOnMachineFunction (MachineFunction &MF) {
1659
1661
if (skipFunction (MF.getFunction ()))
1660
1662
return false ;
1661
- auto *DT = &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree ();
1663
+ auto *DT = Aggressive
1664
+ ? &getAnalysis<MachineDominatorTreeWrapperPass>().getDomTree ()
1665
+ : nullptr ;
1662
1666
auto *MLI = &getAnalysis<MachineLoopInfoWrapperPass>().getLI ();
1663
1667
PeepholeOptimizer Impl (DT, MLI);
1664
1668
return Impl.run (MF);
@@ -1788,7 +1792,7 @@ bool PeepholeOptimizer::run(MachineFunction &MF) {
1788
1792
MachineInstr *Dead = &*MII;
1789
1793
++MII;
1790
1794
MachineBasicBlock *DeadDest = TII->getBranchDestBlock (*Dead);
1791
- if (TII->getBranchDestBlock (*NewBr)!= DeadDest)
1795
+ if (DT && TII->getBranchDestBlock (*NewBr) != DeadDest)
1792
1796
DT->deleteEdge (&MBB, DeadDest);
1793
1797
Dead->eraseFromParent ();
1794
1798
}
0 commit comments