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