comparison lib/Transforms/Scalar/ConstantProp.cpp @ 83:60c9769439b8

LLVM 3.7
author Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp>
date Wed, 18 Feb 2015 14:55:36 +0900
parents 54457678186b
children afa8332a0e37
comparison
equal deleted inserted replaced
78:af83660cff7b 83:60c9769439b8
24 #include "llvm/IR/Constant.h" 24 #include "llvm/IR/Constant.h"
25 #include "llvm/IR/DataLayout.h" 25 #include "llvm/IR/DataLayout.h"
26 #include "llvm/IR/InstIterator.h" 26 #include "llvm/IR/InstIterator.h"
27 #include "llvm/IR/Instruction.h" 27 #include "llvm/IR/Instruction.h"
28 #include "llvm/Pass.h" 28 #include "llvm/Pass.h"
29 #include "llvm/Target/TargetLibraryInfo.h" 29 #include "llvm/Analysis/TargetLibraryInfo.h"
30 #include <set> 30 #include <set>
31 using namespace llvm; 31 using namespace llvm;
32 32
33 #define DEBUG_TYPE "constprop" 33 #define DEBUG_TYPE "constprop"
34 34
43 43
44 bool runOnFunction(Function &F) override; 44 bool runOnFunction(Function &F) override;
45 45
46 void getAnalysisUsage(AnalysisUsage &AU) const override { 46 void getAnalysisUsage(AnalysisUsage &AU) const override {
47 AU.setPreservesCFG(); 47 AU.setPreservesCFG();
48 AU.addRequired<TargetLibraryInfo>(); 48 AU.addRequired<TargetLibraryInfoWrapperPass>();
49 } 49 }
50 }; 50 };
51 } 51 }
52 52
53 char ConstantPropagation::ID = 0; 53 char ConstantPropagation::ID = 0;
54 INITIALIZE_PASS_BEGIN(ConstantPropagation, "constprop", 54 INITIALIZE_PASS_BEGIN(ConstantPropagation, "constprop",
55 "Simple constant propagation", false, false) 55 "Simple constant propagation", false, false)
56 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfo) 56 INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
57 INITIALIZE_PASS_END(ConstantPropagation, "constprop", 57 INITIALIZE_PASS_END(ConstantPropagation, "constprop",
58 "Simple constant propagation", false, false) 58 "Simple constant propagation", false, false)
59 59
60 FunctionPass *llvm::createConstantPropagationPass() { 60 FunctionPass *llvm::createConstantPropagationPass() {
61 return new ConstantPropagation(); 61 return new ConstantPropagation();
68 WorkList.insert(&*i); 68 WorkList.insert(&*i);
69 } 69 }
70 bool Changed = false; 70 bool Changed = false;
71 DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>(); 71 DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
72 const DataLayout *DL = DLP ? &DLP->getDataLayout() : nullptr; 72 const DataLayout *DL = DLP ? &DLP->getDataLayout() : nullptr;
73 TargetLibraryInfo *TLI = &getAnalysis<TargetLibraryInfo>(); 73 TargetLibraryInfo *TLI =
74 &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
74 75
75 while (!WorkList.empty()) { 76 while (!WorkList.empty()) {
76 Instruction *I = *WorkList.begin(); 77 Instruction *I = *WorkList.begin();
77 WorkList.erase(WorkList.begin()); // Get an element from the worklist... 78 WorkList.erase(WorkList.begin()); // Get an element from the worklist...
78 79