32 #define DEBUG_TYPE "constprop"
34 STATISTIC(NumInstKilled,
"Number of instructions killed");
54 "Simple constant propagation",
false,
false)
60 return new ConstantPropagation();
63 bool ConstantPropagation::runOnFunction(
Function &
F) {
65 std::set<Instruction*> WorkList;
72 &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
74 while (!WorkList.empty()) {
76 WorkList.erase(WorkList.begin());
83 WorkList.insert(cast<Instruction>(U));
iplist< Instruction >::iterator eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing basic block and deletes it...
A parsed version of the target data layout string in and methods for querying it. ...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
STATISTIC(NumFunctions,"Total number of functions")
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
inst_iterator inst_begin(Function *F)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
FunctionPass * createConstantPropagationPass()
void initializeConstantPropagationPass(PassRegistry &)
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
This is an important base class in LLVM.
Constant * ConstantFoldInstruction(Instruction *I, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr)
ConstantFoldInstruction - Try to constant fold the specified instruction.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
INITIALIZE_PASS_BEGIN(ConstantPropagation,"constprop","Simple constant propagation", false, false) INITIALIZE_PASS_END(ConstantPropagation
Provides information about what library functions are available for the current target.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
iterator_range< user_iterator > users()
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Simple constant propagation
Module * getParent()
Get the module that this global value is contained inside of...
inst_iterator inst_end(Function *F)