34 #define DEBUG_TYPE "bdce"
36 STATISTIC(NumRemoved,
"Number of instructions removed (unused)");
37 STATISTIC(NumSimplified,
"Number of instructions trivialized (dead bits)");
52 WorkList.push_back(J);
57 while (!WorkList.empty()) {
74 WorkList.push_back(K);
86 if (
I.mayHaveSideEffects() &&
I.use_empty())
89 if (
I.getType()->isIntegerTy() &&
94 DEBUG(
dbgs() <<
"BDCE: Trivializing: " <<
I <<
" (all bits dead)\n");
103 I.replaceNonMetadataUsesWith(Zero);
110 I.dropAllReferences();
116 I->eraseFromParent();
140 bool runOnFunction(
Function &
F)
override {
143 auto &DB = getAnalysis<DemandedBitsWrapperPass>().getDemandedBits();
157 "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)
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs...ExtraArgs)
Get the result of an analysis pass for a given IR unit.
An analysis that produces DemandedBits for a function.
void dropPoisonGeneratingFlags()
Drops flags that may cause this instruction to evaluate to poison despite having non-poison inputs...
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.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
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
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Type * getType() const
All values are typed, get the type of this value.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
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:
static void clearAssumptionsOfUsers(Instruction *I, DemandedBits &DB)
If an instruction is trivialized (dead), then the chain of users of that instruction may need to be c...
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.
bool isIntegerTy() const
True if this is an instance of IntegerType.
iterator_range< user_iterator > users()
Represents analyses that only rely on functions' control flow.
bool isAllOnesValue() const
Determine if all bits are set.
void preserveSet()
Mark an analysis set as preserved.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
INITIALIZE_PASS_BEGIN(BDCELegacyPass,"bdce","Bit-Tracking Dead Code Elimination", false, false) INITIALIZE_PASS_END(BDCELegacyPass
void preserve()
Mark an analysis as preserved.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
inst_range instructions(Function *F)
A container for analyses that lazily runs them and caches their results.