Go to the documentation of this file.
33 #define DEBUG_TYPE "dce"
35 STATISTIC(DCEEliminated,
"Number of insts removed");
37 "Controls which instructions are eliminated");
44 struct RedundantDbgInstElimination :
public FunctionPass {
66 "Redundant Dbg Instruction Elimination",
false,
false)
69 return new RedundantDbgInstElimination();
100 for (
unsigned i = 0,
e =
I->getNumOperands();
i !=
e; ++
i) {
102 I->setOperand(
i,
nullptr);
115 I->eraseFromParent();
123 bool MadeChange =
false;
135 while (!WorkList.
empty()) {
163 &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
F);
176 INITIALIZE_PASS(DCELegacyPass,
"dce",
"Dead Code Elimination",
false,
false)
179 return new DCELegacyPass();
A set of analyses that are preserved following a run of a transformation pass.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
static bool DCEInstruction(Instruction *I, SmallSetVector< Instruction *, 16 > &WorkList, const TargetLibraryInfo *TLI)
This is an optimization pass for GlobalISel generic memory operations.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Represent the analysis usage information of a pass.
static bool shouldExecute(unsigned CounterName)
STATISTIC(NumFunctions, "Total number of functions")
bool RemoveRedundantDbgInstrs(BasicBlock *BB)
Try to remove redundant dbg.value instructions from given basic block.
bool empty() const
Determine if the SetVector is empty or not.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Pass * createRedundantDbgInstEliminationPass()
inst_range instructions(Function *F)
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
INITIALIZE_PASS(RedundantDbgInstElimination, "redundant-dbg-inst-elim", "Redundant Dbg Instruction Elimination", false, false) Pass *llvm
void salvageKnowledge(Instruction *I, AssumptionCache *AC=nullptr, DominatorTree *DT=nullptr)
Calls BuildAssumeFromInst and if the resulting llvm.assume is valid insert if before I.
bool insert(const value_type &X)
Insert a new element into the SetVector.
bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction is not used, and the instruction will return.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
Represents analyses that only rely on functions' control flow.
void initializeDCELegacyPassPass(PassRegistry &)
static bool runOnFunction(Function &F, bool PostInlining)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
DEBUG_COUNTER(DCECounter, "dce-transform", "Controls which instructions are eliminated")
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
void salvageDebugInfo(Instruction &I)
Assuming the instruction I is going to be deleted, attempt to salvage debug users of I by writing the...
Provides information about what library functions are available for the current target.
void initializeRedundantDbgInstEliminationPass(PassRegistry &)
Pass interface - Implemented by all 'passes'.
void preserveSet()
Mark an analysis set as preserved.
A SetVector that performs no allocations if smaller than a certain size.
A container for analyses that lazily runs them and caches their results.
FunctionPass class - This class is used to implement most global optimizations.
FunctionPass * createDeadCodeEliminationPass()
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
AnalysisUsage & addRequired()
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
LLVM_NODISCARD T pop_back_val()
static bool eliminateDeadCode(Function &F, TargetLibraryInfo *TLI)
LLVM Value Representation.
Analysis pass providing the TargetLibraryInfo.