33 #define DEBUG_TYPE "bdce"
35 STATISTIC(NumRemoved,
"Number of instructions removed (unused)");
36 STATISTIC(NumSimplified,
"Number of instructions trivialized (dead bits)");
45 if (
I.mayHaveSideEffects() &&
I.use_empty())
48 if (
I.getType()->isIntegerTy() &&
53 DEBUG(
dbgs() <<
"BDCE: Trivializing: " <<
I <<
" (all bits dead)\n");
59 I.replaceNonMetadataUsesWith(Zero);
66 I.dropAllReferences();
96 bool runOnFunction(
Function &
F)
override {
99 auto &DB = getAnalysis<DemandedBitsWrapperPass>().getDemandedBits();
113 "Bit-Tracking Dead Code Elimination",
false,
false)
Legacy wrapper pass to provide the GlobalsAAResult object.
void push_back(const T &Elt)
void initializeBDCELegacyPassPass(PassRegistry &)
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
STATISTIC(NumFunctions,"Total number of functions")
This is the interface for a simple mod/ref and alias analysis over globals.
bool isInstructionDead(Instruction *I)
Return true if, during analysis, I could not be reached.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
static bool bitTrackingDCE(Function &F, DemandedBits &DB)
An analysis that produces DemandedBits for a function.
bool getBoolValue() const
Convert APInt to a boolean value.
Bit Tracking Dead Code false
A set of analyses that are preserved following a run of a transformation pass.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs...ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
Analysis pass providing a never-invalidated alias analysis result.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
FunctionPass * createBitTrackingDCEPass()
FunctionPass class - This class is used to implement most global optimizations.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Bit Tracking Dead Code Elimination
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
APInt getDemandedBits(Instruction *I)
Return the bits demanded from instruction I.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
INITIALIZE_PASS_BEGIN(BDCELegacyPass,"bdce","Bit-Tracking Dead Code Elimination", false, false) INITIALIZE_PASS_END(BDCELegacyPass
LLVM Value Representation.
inst_range instructions(Function *F)
A container for analyses that lazily runs them and caches their results.