35 #define DEBUG_TYPE "constprop" 37 STATISTIC(NumInstKilled,
"Number of instructions killed");
39 "Controls which instructions are killed");
59 "Simple constant propagation",
false,
false)
65 return new ConstantPropagation();
86 &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
88 while (!WorkList.
empty()) {
90 for (
auto *
I : WorkListVec) {
100 for (
User *U :
I->users()) {
102 if (WorkList.
insert(cast<Instruction>(U)).second)
103 NewWorkListVec.
push_back(cast<Instruction>(U));
107 I->replaceAllUsesWith(
C);
110 I->eraseFromParent();
118 WorkListVec = std::move(NewWorkListVec);
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...
This class represents lattice values for constants.
void push_back(const T &Elt)
DEBUG_COUNTER(CPCounter, "constprop-transform", "Controls which instructions are killed")
STATISTIC(NumFunctions, "Total number of functions")
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
FunctionPass * createConstantPropagationPass()
This file provides an implementation of debug counters.
void initializeConstantPropagationPass(PassRegistry &)
static bool runOnFunction(Function &F, bool PostInlining)
This is an important base class in LLVM.
LLVM_NODISCARD bool empty() const
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
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.
static bool shouldExecute(unsigned CounterName)
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
bool erase(PtrType Ptr)
erase - If the set contains the specified pointer, remove it and return true, otherwise return false...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
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:
INITIALIZE_PASS_BEGIN(ConstantPropagation, "constprop", "Simple constant propagation", false, false) INITIALIZE_PASS_END(ConstantPropagation
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)