Deleted Added
full compact
Mem2Reg.cpp (208954) Mem2Reg.cpp (212904)
1//===- Mem2Reg.cpp - The -mem2reg pass, a wrapper around the Utils lib ----===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 13 unchanged lines hidden (view full) ---

22#include "llvm/ADT/Statistic.h"
23using namespace llvm;
24
25STATISTIC(NumPromoted, "Number of alloca's promoted");
26
27namespace {
28 struct PromotePass : public FunctionPass {
29 static char ID; // Pass identification, replacement for typeid
1//===- Mem2Reg.cpp - The -mem2reg pass, a wrapper around the Utils lib ----===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 13 unchanged lines hidden (view full) ---

22#include "llvm/ADT/Statistic.h"
23using namespace llvm;
24
25STATISTIC(NumPromoted, "Number of alloca's promoted");
26
27namespace {
28 struct PromotePass : public FunctionPass {
29 static char ID; // Pass identification, replacement for typeid
30 PromotePass() : FunctionPass(&ID) {}
30 PromotePass() : FunctionPass(ID) {}
31
32 // runOnFunction - To run this pass, first we calculate the alloca
33 // instructions that are safe for promotion, then we promote each one.
34 //
35 virtual bool runOnFunction(Function &F);
36
37 // getAnalysisUsage - We need dominance frontiers
38 //

--- 5 unchanged lines hidden (view full) ---

44 AU.addPreserved<UnifyFunctionExitNodes>();
45 AU.addPreservedID(LowerSwitchID);
46 AU.addPreservedID(LowerInvokePassID);
47 }
48 };
49} // end of anonymous namespace
50
51char PromotePass::ID = 0;
31
32 // runOnFunction - To run this pass, first we calculate the alloca
33 // instructions that are safe for promotion, then we promote each one.
34 //
35 virtual bool runOnFunction(Function &F);
36
37 // getAnalysisUsage - We need dominance frontiers
38 //

--- 5 unchanged lines hidden (view full) ---

44 AU.addPreserved<UnifyFunctionExitNodes>();
45 AU.addPreservedID(LowerSwitchID);
46 AU.addPreservedID(LowerInvokePassID);
47 }
48 };
49} // end of anonymous namespace
50
51char PromotePass::ID = 0;
52static RegisterPass<PromotePass> X("mem2reg", "Promote Memory to Register");
52INITIALIZE_PASS(PromotePass, "mem2reg", "Promote Memory to Register",
53 false, false);
53
54bool PromotePass::runOnFunction(Function &F) {
55 std::vector<AllocaInst*> Allocas;
56
57 BasicBlock &BB = F.getEntryBlock(); // Get the entry node for the function
58
59 bool Changed = false;
60

--- 15 unchanged lines hidden (view full) ---

76 PromoteMemToReg(Allocas, DT, DF);
77 NumPromoted += Allocas.size();
78 Changed = true;
79 }
80
81 return Changed;
82}
83
54
55bool PromotePass::runOnFunction(Function &F) {
56 std::vector<AllocaInst*> Allocas;
57
58 BasicBlock &BB = F.getEntryBlock(); // Get the entry node for the function
59
60 bool Changed = false;
61

--- 15 unchanged lines hidden (view full) ---

77 PromoteMemToReg(Allocas, DT, DF);
78 NumPromoted += Allocas.size();
79 Changed = true;
80 }
81
82 return Changed;
83}
84
84// Publically exposed interface to pass...
85const PassInfo *const llvm::PromoteMemoryToRegisterID = &X;
86// createPromoteMemoryToRegister - Provide an entry point to create this pass.
87//
88FunctionPass *llvm::createPromoteMemoryToRegisterPass() {
89 return new PromotePass();
90}
85// createPromoteMemoryToRegister - Provide an entry point to create this pass.
86//
87FunctionPass *llvm::createPromoteMemoryToRegisterPass() {
88 return new PromotePass();
89}