[llvm] r348390 - [MachineOutliner][NFC] Don't create outlined sequence from integer mapping
Jessica Paquette via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 5 09:57:34 PST 2018
Author: paquette
Date: Wed Dec 5 09:57:33 2018
New Revision: 348390
URL: http://llvm.org/viewvc/llvm-project?rev=348390&view=rev
Log:
[MachineOutliner][NFC] Don't create outlined sequence from integer mapping
Some gardening/refactoring.
It's cleaner to copy the instructions into the MachineFunction using the first
candidate instead of going to the mapper.
Also, by doing this we can remove the Seq member from OutlinedFunction entirely.
Modified:
llvm/trunk/include/llvm/CodeGen/MachineOutliner.h
llvm/trunk/lib/CodeGen/MachineOutliner.cpp
Modified: llvm/trunk/include/llvm/CodeGen/MachineOutliner.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineOutliner.h?rev=348390&r1=348389&r2=348390&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineOutliner.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineOutliner.h Wed Dec 5 09:57:33 2018
@@ -179,10 +179,6 @@ public:
/// This is initialized after we go through and create the actual function.
MachineFunction *MF = nullptr;
- /// The sequence of integers corresponding to the instructions in this
- /// function.
- std::vector<unsigned> Sequence;
-
/// Represents the size of a sequence in bytes. (Some instructions vary
/// widely in size, so just counting the instructions isn't very useful.)
unsigned SequenceSize;
@@ -225,6 +221,9 @@ public:
: NotOutlinedCost - OutlinedCost;
}
+ /// Return the number of instructions in this sequence.
+ unsigned getNumInstrs() const { return Candidates[0]->getLength(); }
+
OutlinedFunction(std::vector<Candidate> &Cands,
unsigned SequenceSize, unsigned FrameOverhead,
unsigned FrameConstructionID)
Modified: llvm/trunk/lib/CodeGen/MachineOutliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineOutliner.cpp?rev=348390&r1=348389&r2=348390&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineOutliner.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineOutliner.cpp Wed Dec 5 09:57:33 2018
@@ -1041,7 +1041,7 @@ void MachineOutliner::emitOutlinedFuncti
MachineOptimizationRemark R(DEBUG_TYPE, "OutlinedFunction",
MBB->findDebugLoc(MBB->begin()), MBB);
R << "Saved " << NV("OutliningBenefit", OF.getBenefit()) << " bytes by "
- << "outlining " << NV("Length", OF.Sequence.size()) << " instructions "
+ << "outlining " << NV("Length", OF.getNumInstrs()) << " instructions "
<< "from " << NV("NumOccurrences", OF.getOccurrenceCount())
<< " locations. "
<< "(Found at: ";
@@ -1139,12 +1139,6 @@ unsigned MachineOutliner::findCandidates
if (OF.Candidates.size() < 2)
continue;
- std::vector<unsigned> Seq;
- unsigned StartIdx = RS.StartIndices[0]; // Grab any start index.
- for (unsigned i = StartIdx; i < StartIdx + StringLen; i++)
- Seq.push_back(ST.Str[i]);
- OF.Sequence = Seq;
-
// Is it better to outline this candidate than not?
if (OF.getBenefit() < 1) {
emitNotOutliningCheaperRemark(StringLen, CandidatesForRepeatedSeq, OF);
@@ -1342,7 +1336,8 @@ MachineOutliner::createOutlinedFunction(
// function. This makes sure the outlined function knows what kinds of
// instructions are going into it. This is fine, since all parent functions
// must necessarily support the instructions that are in the outlined region.
- const Function &ParentFn = OF.Candidates.front()->getMF()->getFunction();
+ Candidate &FirstCand = *OF.Candidates.front();
+ const Function &ParentFn = FirstCand.getMF()->getFunction();
if (ParentFn.hasFnAttribute("target-features"))
F->addFnAttr(ParentFn.getFnAttribute("target-features"));
@@ -1359,11 +1354,9 @@ MachineOutliner::createOutlinedFunction(
// Insert the new function into the module.
MF.insert(MF.begin(), &MBB);
- // Copy over the instructions for the function using the integer mappings in
- // its sequence.
- for (unsigned Str : OF.Sequence) {
- MachineInstr *NewMI =
- MF.CloneMachineInstr(Mapper.IntegerInstructionMap.find(Str)->second);
+ for (auto I = FirstCand.front(), E = std::next(FirstCand.back()); I != E;
+ ++I) {
+ MachineInstr *NewMI = MF.CloneMachineInstr(&*I);
NewMI->dropMemRefs(MF);
// Don't keep debug information for outlined instructions.
More information about the llvm-commits
mailing list