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; @@ -503,20 +503,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<MachineInstr *, 16> InsInstrs, - SmallVector<MachineInstr *, 16> DelInstrs, - MachineTraceMetrics::Ensemble *MinInstr, - SparseSet<LiveRegUnit> &RegUnits, - const TargetInstrInfo *TII, - MachineCombinerPattern Pattern, - bool IncrementalUpdate) { +static void insertDeleteInstructions( + MachineBasicBlock *MBB, MachineInstr &MI, + SmallVector<MachineInstr *, 16> InsInstrs, + SmallVector<MachineInstr *, 16> DelInstrs, + MachineTraceMetrics::Ensemble *TraceEnsemble, + SparseSet<LiveRegUnit> &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 @@ -542,9 +541,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++; } @@ -570,7 +569,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."); @@ -594,8 +593,8 @@ decltype(BlockIter) LastUpdate; // Check if the block is in a loop. const MachineLoop *ML = MLI->getLoopFor(MBB); - if (!MinInstr) - MinInstr = Traces->getEnsemble(MachineTraceMetrics::TS_MinInstrCount); + if (!TraceEnsemble) + TraceEnsemble = Traces->getEnsemble(MachineTraceMetrics::TS_MinInstrCount); SparseSet<LiveRegUnit> RegUnits; RegUnits.setUniverse(TRI->getNumRegUnits()); @@ -673,7 +672,7 @@ if (IncrementalUpdate && LastUpdate != BlockIter) { // Update depths since the last incremental update. - MinInstr->updateDepths(LastUpdate, BlockIter, RegUnits); + TraceEnsemble->updateDepths(LastUpdate, BlockIter, RegUnits); LastUpdate = BlockIter; } @@ -687,7 +686,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; @@ -704,7 +703,7 @@ // resource pressure. if (SubstituteAlways || doSubstitute(NewInstCount, OldInstCount, OptForSize)) { - 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; @@ -715,7 +714,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, @@ -727,7 +726,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. @@ -762,7 +761,7 @@ MBFI = (PSI && PSI->hasProfileSummary()) ? &getAnalysis<LazyMachineBlockFrequencyInfoPass>().getBFI() : nullptr; - MinInstr = nullptr; + TraceEnsemble = nullptr; OptSize = MF.getFunction().hasOptSize(); RegClassInfo.runOnMachineFunction(MF);