33 #define DEBUG_TYPE "instsimplify"
35 STATISTIC(NumSimplified,
"Number of redundant instructions removed");
52 if (!ToSimplify->
empty() && !ToSimplify->
count(I))
60 Next->insert(cast<Instruction>(U));
81 }
while (!ToSimplify->
empty());
101 bool runOnFunction(
Function &
F)
override {
106 &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
108 &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
110 &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
111 return runImpl(F, DT, TLI, AC);
118 "Remove redundant instructions",
false,
false)
128 return new InstSimplifier();
136 bool Changed =
runImpl(F, &DT, &TLI, &AC);
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...
STATISTIC(NumFunctions,"Total number of functions")
size_type count(PtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
An immutable pass that tracks lazily created AssumptionCache objects.
A cache of .assume calls within a function.
Analysis pass which computes a DominatorTree.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
char & InstructionSimplifierID
INITIALIZE_PASS_BEGIN(InstSimplifier,"instsimplify","Remove redundant instructions", false, false) INITIALIZE_PASS_END(InstSimplifier
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
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.
LLVM Basic Block Representation.
static bool runImpl(Function &F, const DominatorTree *DT, const TargetLibraryInfo *TLI, AssumptionCache *AC)
Represent the analysis usage information of a pass.
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE,"Assign register bank of generic virtual registers", false, false) RegBankSelect
FunctionPass class - This class is used to implement most global optimizations.
void initializeInstSimplifierPass(PassRegistry &)
LLVM_NODISCARD bool empty() const
bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=nullptr)
If the specified value is a trivially dead instruction, delete it.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
A function analysis which provides an AssumptionCache.
Iterator for intrusive lists based on ilist_node.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
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:
const BasicBlock & getEntryBlock() const
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
iterator_range< user_iterator > users()
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Analysis pass providing the TargetLibraryInfo.
iterator_range< df_iterator< T > > depth_first(const T &G)
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
inst_range instructions(Function *F)
A container for analyses that lazily runs them and caches their results.
Value * SimplifyInstruction(Instruction *I, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr, const DominatorTree *DT=nullptr, AssumptionCache *AC=nullptr)
See if we can compute a simplified version of this instruction.
Legacy analysis pass which computes a DominatorTree.
FunctionPass * createInstructionSimplifierPass()