aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineOutliner.cpp
diff options
context:
space:
mode:
authorJessica Paquette <jpaquette@apple.com>2018-12-05 23:24:22 +0000
committerJessica Paquette <jpaquette@apple.com>2018-12-05 23:24:22 +0000
commite18d6ff036fe8d62e19d9dc44f103c3d7ead9c64 (patch)
treeeeb296c7f2240dd1751f64f1c184c1cd467023e4 /llvm/lib/CodeGen/MachineOutliner.cpp
parent5ff7b8a04aa720456a36355f6ae20912cb2fcd86 (diff)
downloadllvm-e18d6ff036fe8d62e19d9dc44f103c3d7ead9c64.zip
llvm-e18d6ff036fe8d62e19d9dc44f103c3d7ead9c64.tar.gz
llvm-e18d6ff036fe8d62e19d9dc44f103c3d7ead9c64.tar.bz2
[MachineOutliner][NFC] Candidates don't need to be shared_ptrs anymore
More refactoring. After the changes to the pruning logic, and removing CandidateList, there's no reason for Candiates to be shared_ptrs (or pointers at all). std::shared_ptr<Candidate> -> Candidate. llvm-svn: 348427
Diffstat (limited to 'llvm/lib/CodeGen/MachineOutliner.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineOutliner.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp
index 0770367..9be5a1f 100644
--- a/llvm/lib/CodeGen/MachineOutliner.cpp
+++ b/llvm/lib/CodeGen/MachineOutliner.cpp
@@ -904,7 +904,7 @@ struct MachineOutliner : public ModulePass {
InstructionMapper &Mapper);
/// Creates a function for \p OF and inserts it into the module.
- MachineFunction *createOutlinedFunction(Module &M, const OutlinedFunction &OF,
+ MachineFunction *createOutlinedFunction(Module &M, OutlinedFunction &OF,
InstructionMapper &Mapper,
unsigned Name);
@@ -931,8 +931,8 @@ struct MachineOutliner : public ModulePass {
/// function for remark emission.
DISubprogram *getSubprogramOrNull(const OutlinedFunction &OF) {
DISubprogram *SP;
- for (const std::shared_ptr<Candidate> &C : OF.Candidates)
- if (C && C->getMF() && (SP = C->getMF()->getFunction().getSubprogram()))
+ for (const Candidate &C : OF.Candidates)
+ if (C.getMF() && (SP = C.getMF()->getFunction().getSubprogram()))
return SP;
return nullptr;
}
@@ -1021,7 +1021,7 @@ void MachineOutliner::emitOutlinedFunctionRemark(OutlinedFunction &OF) {
for (size_t i = 0, e = OF.Candidates.size(); i < e; i++) {
R << NV((Twine("StartLoc") + Twine(i)).str(),
- OF.Candidates[i]->front()->getDebugLoc());
+ OF.Candidates[i].front()->getDebugLoc());
if (i != e - 1)
R << ", ";
}
@@ -1134,7 +1134,7 @@ unsigned MachineOutliner::buildCandidateList(
}
MachineFunction *
-MachineOutliner::createOutlinedFunction(Module &M, const OutlinedFunction &OF,
+MachineOutliner::createOutlinedFunction(Module &M, OutlinedFunction &OF,
InstructionMapper &Mapper,
unsigned Name) {
@@ -1169,7 +1169,7 @@ 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.
- Candidate &FirstCand = *OF.Candidates.front();
+ Candidate &FirstCand = OF.Candidates.front();
const Function &ParentFn = FirstCand.getMF()->getFunction();
if (ParentFn.hasFnAttribute("target-features"))
F->addFnAttr(ParentFn.getFnAttribute("target-features"));
@@ -1259,10 +1259,10 @@ bool MachineOutliner::outline(Module &M,
for (OutlinedFunction &OF : FunctionList) {
// If we outlined something that overlapped with a candidate in a previous
// step, then we can't outline from it.
- erase_if(OF.Candidates, [&Mapper](std::shared_ptr<Candidate> &C) {
+ erase_if(OF.Candidates, [&Mapper](Candidate &C) {
return std::any_of(
- Mapper.UnsignedVec.begin() + C->getStartIdx(),
- Mapper.UnsignedVec.begin() + C->getEndIdx() + 1,
+ Mapper.UnsignedVec.begin() + C.getStartIdx(),
+ Mapper.UnsignedVec.begin() + C.getEndIdx() + 1,
[](unsigned I) { return (I == static_cast<unsigned>(-1)); });
});
@@ -1281,8 +1281,7 @@ bool MachineOutliner::outline(Module &M,
const TargetInstrInfo &TII = *STI.getInstrInfo();
// Replace occurrences of the sequence with calls to the new function.
- for (std::shared_ptr<Candidate> &Cptr : OF.Candidates) {
- Candidate &C = *Cptr;
+ for (Candidate &C : OF.Candidates) {
MachineBasicBlock &MBB = *C.getMBB();
MachineBasicBlock::iterator StartIt = C.front();
MachineBasicBlock::iterator EndIt = C.back();