Go to the documentation of this file.
25 #define DEBUG_TYPE "instsimplify"
27 STATISTIC(NumSimplified,
"Number of redundant instructions removed");
51 DeadInstsInBB.push_back(&
I);
53 }
else if (!
I.use_empty()) {
56 for (
User *U :
I.users())
57 Next->
insert(cast<Instruction>(U));
58 I.replaceAllUsesWith(V);
63 DeadInstsInBB.push_back(&
I);
74 }
while (!ToSimplify->
empty());
100 &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
102 &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
F);
104 &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(
F);
106 &getAnalysis<OptimizationRemarkEmitterWrapperPass>().getORE();
116 "Remove redundant instructions",
false,
false)
126 return new InstSimplifyLegacyPass();
137 bool Changed =
runImpl(
F, SQ, &ORE);
A set of analyses that are preserved following a run of a transformation pass.
bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr, std::function< void(Value *)> AboutToDeleteCallback=std::function< void(Value *)>())
If the specified value is a trivially dead instruction, delete it.
This is an optimization pass for GlobalISel generic memory operations.
A parsed version of the target data layout string in and methods for querying it.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
void initializeInstSimplifyLegacyPassPass(PassRegistry &)
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
LLVM Basic Block Representation.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Represent the analysis usage information of a pass.
Value * SimplifyInstruction(Instruction *I, const SimplifyQuery &Q, OptimizationRemarkEmitter *ORE=nullptr)
See if we can compute a simplified version of this instruction.
Legacy analysis pass which computes a DominatorTree.
STATISTIC(NumFunctions, "Total number of functions")
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
inst_range instructions(Function *F)
INITIALIZE_PASS_BEGIN(InstSimplifyLegacyPass, "instsimplify", "Remove redundant instructions", false, false) INITIALIZE_PASS_END(InstSimplifyLegacyPass
A function analysis which provides an AssumptionCache.
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
const TargetLibraryInfo * TLI
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
An immutable pass that tracks lazily created AssumptionCache objects.
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:
A cache of @llvm.assume calls within a function.
Represents analyses that only rely on functions' control flow.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static bool runOnFunction(Function &F, bool PostInlining)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Provides information about what library functions are available for the current target.
FunctionPass * createInstSimplifyLegacyPass()
static bool runImpl(Function &F, const SimplifyQuery &SQ, OptimizationRemarkEmitter *ORE)
Analysis pass which computes a DominatorTree.
void preserveSet()
Mark an analysis set as preserved.
LLVM_NODISCARD bool empty() const
A container for analyses that lazily runs them and caches their results.
FunctionPass class - This class is used to implement most global optimizations.
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()
LLVM Value Representation.
Analysis pass providing the TargetLibraryInfo.
iterator insert(iterator I, T &&Elt)