diff --git a/llvm/lib/Target/PowerPC/PPCSimpleOutliner.cpp b/llvm/lib/Target/PowerPC/PPCSimpleOutliner.cpp --- a/llvm/lib/Target/PowerPC/PPCSimpleOutliner.cpp +++ b/llvm/lib/Target/PowerPC/PPCSimpleOutliner.cpp @@ -40,6 +40,7 @@ #include "PPC.h" #include "PPCTargetMachine.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/TargetPassConfig.h" @@ -58,9 +59,7 @@ STATISTIC(NumTailCallsEnabled, "Number of tail calls enabled by the PPC outliner"); -namespace llvm { -void initializePPCSimpleOutlinerPass(PassRegistry &); -} +void llvm::initializePPCSimpleOutlinerPass(PassRegistry &); namespace { class PPCSimpleOutliner : public ModulePass { @@ -77,6 +76,16 @@ bool runOnModule(Module &M) override; }; +} // Anonymous namespace. + +INITIALIZE_PASS(PPCSimpleOutliner, DEBUG_TYPE, + "Recognize idioms that are useful to transform on PPC", false, + false) + +char PPCSimpleOutliner::ID = 0; +ModulePass *llvm::createPPCSimpleOutlinerPass() { + return new PPCSimpleOutliner(); +} // We are looking for a block that simply has a PHI and a return. static bool isSimpleReturnBB(BasicBlock *BB, ReturnInst *&RetInst, @@ -126,14 +135,14 @@ ReturnInst *&PossibleRetInst) { for (Instruction &I : BB) { if (isa(I)) { - for (User *user : I.users()) { - Instruction *UserInst = dyn_cast(user); + for (User *User : I.users()) { + Instruction *UserInst = dyn_cast(User); if (UserInst->isUsedInBasicBlock(&BB)) continue; // LLVM_DEBUG(dbgs() << "is in entry\n"); else if (dyn_cast(UserInst) && UserInst->hasOneUse()) - if (auto ret = dyn_cast(*(UserInst->user_begin()))) { + if (auto Ret = dyn_cast(*(UserInst->user_begin()))) { // LLVM_DEBUG(dbgs() << "is PHINode, only use is ret.\n"); - PossibleRetInst = ret; + PossibleRetInst = Ret; continue; } LLVM_DEBUG(dbgs() << "load used outside of entry and not by a ret:\n"); @@ -203,10 +212,10 @@ return false; } - std::vector Args; + SmallVector Args; for (Argument &Arg : F.args()) { if (Arg.hasPassPointeeByValueAttr()) { - LLVM_DEBUG(dbgs() << "Function argument is on the HEAP"); + LLVM_DEBUG(dbgs() << "Function argument is passed by value"); return false; } Args.push_back(&Arg); @@ -232,8 +241,8 @@ LLVM_DEBUG(SimpleRetSucc->dump()); LLVM_DEBUG(dbgs() << "Function is outline-able\n"); - ValueToValueMapTy dummy; - Function *NewF = CloneFunction(&F, dummy); + ValueToValueMapTy Dummy; + Function *NewF = CloneFunction(&F, Dummy); NewF->setCallingConv(CallingConv::Fast); NewF->addFnAttr(Attribute::NoInline); NewF->setLinkage(GlobalValue::InternalLinkage); @@ -264,6 +273,7 @@ ReturnInst::Create(OutlineCallBB->getContext(), OutlineCall, OutlineCallBB); OutlineCall->setTailCall(); OutlineCall->setDebugLoc(BranchFromEntry->getDebugLoc()); + NumTailCallsEnabled++; LLVM_DEBUG(dbgs() << "Old function:\n"); LLVM_DEBUG(F.dump()); LLVM_DEBUG(dbgs() << "Cloned function:\n"); @@ -285,21 +295,9 @@ LLVM_DEBUG(dbgs() << "PPC Simple Function Outliner\n"); LLVM_DEBUG(F.dump()); - if (ClonedFunctions.count(&F) == 0) + if (!ClonedFunctions.count(&F)) Changed |= tryOutlining(F); } return Changed; } -} // namespace - -INITIALIZE_PASS(PPCSimpleOutliner, DEBUG_TYPE, - "Recognize idioms that are useful to transform on PPC", false, - false) - -// namespace llvm{ -char PPCSimpleOutliner::ID = 0; -ModulePass *llvm::createPPCSimpleOutlinerPass() { - return new PPCSimpleOutliner(); -} -//}//namespace llvm