33 #define DEBUG_TYPE "constprop"
35 STATISTIC(NumInstKilled,
"Number of instructions killed");
55 "Simple constant propagation",
false,
false)
61 return new ConstantPropagation();
64 bool ConstantPropagation::runOnFunction(
Function &
F) {
69 std::set<Instruction*> WorkList;
76 &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
78 while (!WorkList.empty()) {
80 WorkList.erase(WorkList.begin());
87 WorkList.insert(cast<Instruction>(U));
SymbolTableList< Instruction >::iterator 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)
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.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
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:
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
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...
bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction is not used, and the instruction has no side ef...
inst_range instructions(Function *F)