32 #define DEBUG_TYPE "instsimplify"
34 STATISTIC(NumSimplified,
"Number of redundant instructions removed");
50 bool runOnFunction(
Function &
F)
override {
52 getAnalysisIfAvailable<DominatorTreeWrapperPass>();
56 &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
58 &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
71 if (!ToSimplify->
empty() && !ToSimplify->
count(I))
78 Next->insert(cast<Instruction>(U));
89 BI = BB->begin(); BE = BB->end();
98 }
while (!ToSimplify->
empty());
107 "Remove redundant instructions",
false,
false)
116 return new InstSimplifier();
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...
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
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.
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
DominatorTree & getDomTree()
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...
LLVM Basic Block Representation.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
void initializeInstSimplifierPass(PassRegistry &)
bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=nullptr)
RecursivelyDeleteTriviallyDeadInstructions - If the specified value is a trivially dead instruction...
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.
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.
Value * SimplifyInstruction(Instruction *I, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr, const DominatorTree *DT=nullptr, AssumptionCache *AC=nullptr)
SimplifyInstruction - See if we can compute a simplified version of this instruction.
Legacy analysis pass which computes a DominatorTree.
FunctionPass * createInstructionSimplifierPass()
Remove redundant instructions