diff options
Diffstat (limited to 'llvm/lib/Transforms/Utils/Mem2Reg.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/Mem2Reg.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/Utils/Mem2Reg.cpp b/llvm/lib/Transforms/Utils/Mem2Reg.cpp index b659a2e4463..29f289b62da 100644 --- a/llvm/lib/Transforms/Utils/Mem2Reg.cpp +++ b/llvm/lib/Transforms/Utils/Mem2Reg.cpp @@ -15,12 +15,17 @@ #include "llvm/Transforms/Utils/Mem2Reg.h" #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/AssumptionCache.h" +#include "llvm/IR/BasicBlock.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Function.h" #include "llvm/IR/Instructions.h" +#include "llvm/IR/PassManager.h" +#include "llvm/Pass.h" +#include "llvm/Support/Casting.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/PromoteMemToReg.h" -#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h" +#include <vector> + using namespace llvm; #define DEBUG_TYPE "mem2reg" @@ -33,7 +38,7 @@ static bool promoteMemoryToRegister(Function &F, DominatorTree &DT, BasicBlock &BB = F.getEntryBlock(); // Get the entry node for the function bool Changed = false; - while (1) { + while (true) { Allocas.clear(); // Find allocas that are safe to promote, by looking at all instructions in @@ -65,15 +70,17 @@ PreservedAnalyses PromotePass::run(Function &F, FunctionAnalysisManager &AM) { } namespace { + struct PromoteLegacyPass : public FunctionPass { - static char ID; // Pass identification, replacement for typeid + // Pass identification, replacement for typeid + static char ID; + PromoteLegacyPass() : FunctionPass(ID) { initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry()); } // runOnFunction - To run this pass, first we calculate the alloca // instructions that are safe for promotion, then we promote each one. - // bool runOnFunction(Function &F) override { if (skipFunction(F)) return false; @@ -89,10 +96,12 @@ struct PromoteLegacyPass : public FunctionPass { AU.addRequired<DominatorTreeWrapperPass>(); AU.setPreservesCFG(); } - }; -} // end of anonymous namespace +}; + +} // end anonymous namespace char PromoteLegacyPass::ID = 0; + INITIALIZE_PASS_BEGIN(PromoteLegacyPass, "mem2reg", "Promote Memory to " "Register", false, false) @@ -102,7 +111,6 @@ INITIALIZE_PASS_END(PromoteLegacyPass, "mem2reg", "Promote Memory to Register", false, false) // createPromoteMemoryToRegister - Provide an entry point to create this pass. -// FunctionPass *llvm::createPromoteMemoryToRegisterPass() { return new PromoteLegacyPass(); } |