diff --git a/llvm/lib/CodeGen/MachineCombiner.cpp b/llvm/lib/CodeGen/MachineCombiner.cpp --- a/llvm/lib/CodeGen/MachineCombiner.cpp +++ b/llvm/lib/CodeGen/MachineCombiner.cpp @@ -70,7 +70,7 @@ MachineRegisterInfo *MRI; MachineLoopInfo *MLI; // Current MachineLoopInfo MachineTraceMetrics *Traces; - MachineTraceMetrics::Ensemble *MinInstr; + MachineTraceMetrics::Ensemble *TraceEnsemble; MachineBlockFrequencyInfo *MBFI; ProfileSummaryInfo *PSI; RegisterClassInfo RegClassInfo; @@ -491,20 +491,19 @@ /// \param MI current machine instruction /// \param InsInstrs new instructions to insert in \p MBB /// \param DelInstrs instruction to delete from \p MBB -/// \param MinInstr is a pointer to the machine trace information +/// \param TraceEnsemble is a pointer to the machine trace information /// \param RegUnits set of live registers, needed to compute instruction depths /// \param TII is target instruction info, used to call target hook /// \param Pattern is used to call target hook finalizeInsInstrs /// \param IncrementalUpdate if true, compute instruction depths incrementally, /// otherwise invalidate the trace -static void insertDeleteInstructions(MachineBasicBlock *MBB, MachineInstr &MI, - SmallVector InsInstrs, - SmallVector DelInstrs, - MachineTraceMetrics::Ensemble *MinInstr, - SparseSet &RegUnits, - const TargetInstrInfo *TII, - MachineCombinerPattern Pattern, - bool IncrementalUpdate) { +static void insertDeleteInstructions( + MachineBasicBlock *MBB, MachineInstr &MI, + SmallVector InsInstrs, + SmallVector DelInstrs, + MachineTraceMetrics::Ensemble *TraceEnsemble, + SparseSet &RegUnits, const TargetInstrInfo *TII, + MachineCombinerPattern Pattern, bool IncrementalUpdate) { // If we want to fix up some placeholder for some target, do it now. // We need this because in genAlternativeCodeSequence, we have not decided the // better pattern InsInstrs or DelInstrs, so we don't want generate some @@ -530,9 +529,9 @@ if (IncrementalUpdate) for (auto *InstrPtr : InsInstrs) - MinInstr->updateDepth(MBB, *InstrPtr, RegUnits); + TraceEnsemble->updateDepth(MBB, *InstrPtr, RegUnits); else - MinInstr->invalidate(MBB); + TraceEnsemble->invalidate(MBB); NumInstCombined++; } @@ -558,7 +557,7 @@ unsigned NewRootLatency, RootLatency; std::tie(NewRootLatency, RootLatency) = getLatenciesForInstrSequences( - Root, InsInstrs, DelInstrs, MinInstr->getTrace(MBB)); + Root, InsInstrs, DelInstrs, TraceEnsemble->getTrace(MBB)); long CurrentLatencyDiff = ((long)RootLatency) - ((long)NewRootLatency); assert(CurrentLatencyDiff <= PrevLatencyDiff && "Current pattern is better than previous pattern."); @@ -582,8 +581,8 @@ decltype(BlockIter) LastUpdate; // Check if the block is in a loop. const MachineLoop *ML = MLI->getLoopFor(MBB); - if (!MinInstr) - MinInstr = Traces->getEnsemble(MachineTraceStrategy::TS_MinInstrCount); + if (!TraceEnsemble) + TraceEnsemble = Traces->getEnsemble(MachineTraceStrategy::TS_MinInstrCount); SparseSet RegUnits; RegUnits.setUniverse(TRI->getNumRegUnits()); @@ -655,7 +654,7 @@ if (IncrementalUpdate && LastUpdate != BlockIter) { // Update depths since the last incremental update. - MinInstr->updateDepths(LastUpdate, BlockIter, RegUnits); + TraceEnsemble->updateDepths(LastUpdate, BlockIter, RegUnits); LastUpdate = BlockIter; } @@ -669,7 +668,7 @@ } if (reduceRegisterPressure(MI, MBB, InsInstrs, DelInstrs, P)) { // Replace DelInstrs with InsInstrs. - insertDeleteInstructions(MBB, MI, InsInstrs, DelInstrs, MinInstr, + insertDeleteInstructions(MBB, MI, InsInstrs, DelInstrs, TraceEnsemble, RegUnits, TII, P, IncrementalUpdate); Changed |= true; @@ -682,7 +681,7 @@ if (ML && TII->isThroughputPattern(P)) { LLVM_DEBUG(dbgs() << "\t Replacing due to throughput pattern in loop\n"); - insertDeleteInstructions(MBB, MI, InsInstrs, DelInstrs, MinInstr, + insertDeleteInstructions(MBB, MI, InsInstrs, DelInstrs, TraceEnsemble, RegUnits, TII, P, IncrementalUpdate); // Eagerly stop after the first pattern fires. Changed = true; @@ -691,14 +690,14 @@ LLVM_DEBUG(dbgs() << "\t Replacing due to OptForSize (" << InsInstrs.size() << " < " << DelInstrs.size() << ")\n"); - insertDeleteInstructions(MBB, MI, InsInstrs, DelInstrs, MinInstr, + insertDeleteInstructions(MBB, MI, InsInstrs, DelInstrs, TraceEnsemble, RegUnits, TII, P, IncrementalUpdate); // Eagerly stop after the first pattern fires. Changed = true; break; } else if (!TSchedModel.hasInstrSchedModelOrItineraries()) { LLVM_DEBUG(dbgs() << "\t Replacing due to lack of schedule model\n"); - insertDeleteInstructions(MBB, MI, InsInstrs, DelInstrs, MinInstr, + insertDeleteInstructions(MBB, MI, InsInstrs, DelInstrs, TraceEnsemble, RegUnits, TII, P, IncrementalUpdate); // Eagerly stop after the first pattern fires. Changed = true; @@ -709,7 +708,7 @@ // instruction depths incrementally. // NOTE: Only the instruction depths up to MI are accurate. All other // trace information is not updated. - MachineTraceMetrics::Trace BlockTrace = MinInstr->getTrace(MBB); + MachineTraceMetrics::Trace BlockTrace = TraceEnsemble->getTrace(MBB); Traces->verifyAnalysis(); if (improvesCriticalPathLen(MBB, &MI, BlockTrace, InsInstrs, DelInstrs, InstrIdxForVirtReg, P, @@ -721,7 +720,7 @@ LastUpdate = BlockIter; } - insertDeleteInstructions(MBB, MI, InsInstrs, DelInstrs, MinInstr, + insertDeleteInstructions(MBB, MI, InsInstrs, DelInstrs, TraceEnsemble, RegUnits, TII, P, IncrementalUpdate); // Eagerly stop after the first pattern fires. @@ -756,7 +755,7 @@ MBFI = (PSI && PSI->hasProfileSummary()) ? &getAnalysis().getBFI() : nullptr; - MinInstr = nullptr; + TraceEnsemble = nullptr; OptSize = MF.getFunction().hasOptSize(); RegClassInfo.runOnMachineFunction(MF);