bool HexagonExpandCondsets::runOnMachineFunction(MachineFunction &MF) { HII = static_cast<const HexagonInstrInfo*>(MF.getSubtarget().getInstrInfo()); TRI = MF.getSubtarget().getRegisterInfo(); LIS = &getAnalysis<LiveIntervals>(); MRI = &MF.getRegInfo(); DEBUG(MF.print(dbgs() << "Before expand-condsets\n", LIS->getSlotIndexes())); bool Changed = false; // Try to coalesce the target of a mux with one of its sources. // This could eliminate a register copy in some circumstances. Changed |= coalesceSegments(MF); for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { // First, simply split all muxes into a pair of conditional transfers // and update the live intervals to reflect the new arrangement. // This is done mainly to make the live interval update simpler, than it // would be while trying to predicate instructions at the same time. Changed |= splitInBlock(*I); // Traverse all blocks and collapse predicable instructions feeding // conditional transfers into predicated instructions. // Walk over all the instructions again, so we may catch pre-existing // cases that were not created in the previous step. Changed |= predicateInBlock(*I); } for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) postprocessUndefImplicitUses(*I); if (Changed) DEBUG(MF.print(dbgs() << "After expand-condsets\n", LIS->getSlotIndexes())); return Changed; }
bool HexagonRDFOpt::runOnMachineFunction(MachineFunction &MF) { if (skipFunction(*MF.getFunction())) return false; if (RDFLimit.getPosition()) { if (RDFCount >= RDFLimit) return false; RDFCount++; } MDT = &getAnalysis<MachineDominatorTree>(); const auto &MDF = getAnalysis<MachineDominanceFrontier>(); const auto &HII = *MF.getSubtarget<HexagonSubtarget>().getInstrInfo(); const auto &HRI = *MF.getSubtarget<HexagonSubtarget>().getRegisterInfo(); MRI = &MF.getRegInfo(); bool Changed; if (RDFDump) MF.print(dbgs() << "Before " << getPassName() << "\n", nullptr); TargetOperandInfo TOI(HII); DataFlowGraph G(MF, HII, HRI, *MDT, MDF, TOI); // Dead phi nodes are necessary for copy propagation: we can add a use // of a register in a block where it would need a phi node, but which // was dead (and removed) during the graph build time. G.build(BuildOptions::KeepDeadPhis); if (RDFDump) dbgs() << "Starting copy propagation on: " << MF.getName() << '\n' << PrintNode<FuncNode*>(G.getFunc(), G) << '\n'; HexagonCP CP(G); CP.trace(RDFDump); Changed = CP.run(); if (RDFDump) dbgs() << "Starting dead code elimination on: " << MF.getName() << '\n' << PrintNode<FuncNode*>(G.getFunc(), G) << '\n'; HexagonDCE DCE(G, *MRI); DCE.trace(RDFDump); Changed |= DCE.run(); if (Changed) { if (RDFDump) dbgs() << "Starting liveness recomputation on: " << MF.getName() << '\n'; Liveness LV(*MRI, G); LV.trace(RDFDump); LV.computeLiveIns(); LV.resetLiveIns(); LV.resetKills(); } if (RDFDump) MF.print(dbgs() << "After " << getPassName() << "\n", nullptr); return false; }
bool HexagonRDFOpt::runOnMachineFunction(MachineFunction &MF) { if (skipFunction(*MF.getFunction())) return false; if (RDFLimit.getPosition()) { if (RDFCount >= RDFLimit) return false; RDFCount++; } MDT = &getAnalysis<MachineDominatorTree>(); const auto &MDF = getAnalysis<MachineDominanceFrontier>(); const auto &HII = *MF.getSubtarget<HexagonSubtarget>().getInstrInfo(); const auto &HRI = *MF.getSubtarget<HexagonSubtarget>().getRegisterInfo(); MRI = &MF.getRegInfo(); bool Changed; if (RDFDump) MF.print(dbgs() << "Before " << getPassName() << "\n", nullptr); HexagonRegisterAliasInfo HAI(HRI); TargetOperandInfo TOI(HII); DataFlowGraph G(MF, HII, HRI, *MDT, MDF, HAI, TOI); G.build(); if (RDFDump) dbgs() << "Starting copy propagation on: " << MF.getName() << '\n' << PrintNode<FuncNode*>(G.getFunc(), G) << '\n'; HexagonCP CP(G); CP.trace(RDFDump); Changed = CP.run(); if (RDFDump) dbgs() << "Starting dead code elimination on: " << MF.getName() << '\n' << PrintNode<FuncNode*>(G.getFunc(), G) << '\n'; HexagonDCE DCE(G, *MRI); DCE.trace(RDFDump); Changed |= DCE.run(); if (Changed) { if (RDFDump) dbgs() << "Starting liveness recomputation on: " << MF.getName() << '\n'; Liveness LV(*MRI, G); LV.trace(RDFDump); LV.computeLiveIns(); LV.resetLiveIns(); LV.resetKills(); } if (RDFDump) MF.print(dbgs() << "After " << getPassName() << "\n", nullptr); return false; }