aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineOutliner.cpp
diff options
context:
space:
mode:
authorJessica Paquette <jpaquette@apple.com>2018-12-05 17:57:33 +0000
committerJessica Paquette <jpaquette@apple.com>2018-12-05 17:57:33 +0000
commit34b618bf7ed0932ba8cc7eeab8c954fee4913005 (patch)
treeee916bb4d517abeaeb514e3c18ac73935ab6bbd6 /llvm/lib/CodeGen/MachineOutliner.cpp
parentc9e38bade5d63243a7df8f86dd42bac4350e4d73 (diff)
downloadllvm-34b618bf7ed0932ba8cc7eeab8c954fee4913005.zip
llvm-34b618bf7ed0932ba8cc7eeab8c954fee4913005.tar.gz
llvm-34b618bf7ed0932ba8cc7eeab8c954fee4913005.tar.bz2
[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. llvm-svn: 348390
Diffstat (limited to 'llvm/lib/CodeGen/MachineOutliner.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineOutliner.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp
index ccd6c31..5e3ebf1 100644
--- a/llvm/lib/CodeGen/MachineOutliner.cpp
+++ b/llvm/lib/CodeGen/MachineOutliner.cpp
@@ -1041,7 +1041,7 @@ void MachineOutliner::emitOutlinedFunctionRemark(OutlinedFunction &OF) {
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(Module &M, const OutlinedFunction &OF,
// 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(Module &M, const OutlinedFunction &OF,
// 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.