36 #define DEBUG_TYPE "lower-is-constant-intrinsic" 39 "Number of 'is.constant' intrinsic calls handled");
41 "Number of 'objectsize' intrinsic calls handled");
52 bool HasDeadBlocks =
false;
56 for (
auto I : Worklist) {
74 if (Target && Target != Other) {
87 bool HasDeadBlocks =
false;
100 case Intrinsic::is_constant:
101 case Intrinsic::objectsize:
120 case Intrinsic::is_constant:
122 IsConstantIntrinsicsHandled++;
124 case Intrinsic::objectsize:
126 ObjectSizeIntrinsicsHandled++;
133 return !Worklist.empty();
158 auto *TLIP = getAnalysisIfAvailable<TargetLibraryInfoWrapperPass>();
167 "Lower constant intrinsics",
false,
false)
170 return new LowerConstantIntrinsics();
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
static ConstantInt * getFalse(LLVMContext &Context)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
is_zero m_Zero()
Match any null constant or a vector with all elements equal to 0.
This class represents lattice values for constants.
void removePredecessor(BasicBlock *Pred, bool KeepOneInputPHIs=false)
Notify the BasicBlock that the predecessor Pred is no longer able to reach it.
void push_back(const T &Elt)
Optional< std::vector< StOtherPiece > > Other
BasicBlock * getSuccessor(unsigned i) const
STATISTIC(NumFunctions, "Total number of functions")
void initializeLowerConstantIntrinsicsPass(PassRegistry &)
static Value * lowerIsConstantIntrinsic(IntrinsicInst *II)
bool match(Val *V, const Pattern &P)
bool replaceAndRecursivelySimplify(Instruction *I, Value *SimpleV, const TargetLibraryInfo *TLI=nullptr, const DominatorTree *DT=nullptr, AssumptionCache *AC=nullptr, SmallSetVector< Instruction *, 8 > *UnsimplifiedUsers=nullptr)
Replace all uses of 'I' with 'SimpleV' and simplify the uses recursively.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Value * lowerObjectSizeCall(IntrinsicInst *ObjectSize, const DataLayout &DL, const TargetLibraryInfo *TLI, bool MustSucceed)
Try to turn a call to @llvm.objectsize into an integer value of the given Type.
Type * getType() const
All values are typed, get the type of this value.
Value handle that is nullable, but tries to track the Value.
Value * getOperand(unsigned i) const
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static bool runOnFunction(Function &F, bool PostInlining)
static bool lowerConstantIntrinsics(Function &F, const TargetLibraryInfo *TLI)
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
Conditional or Unconditional Branch instruction.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
FunctionPass class - This class is used to implement most global optimizations.
Interval::pred_iterator pred_end(Interval *I)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &)
Run the pass over the function.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
A SetVector that performs no allocations if smaller than a certain size.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Provides information about what library functions are available for the current target.
FunctionPass * createLowerConstantIntrinsicsPass()
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
static ConstantInt * getTrue(LLVMContext &Context)
Target - Wrapper for Target specific information.
static bool replaceConditionalBranchesOnConstant(Instruction *II, Value *NewValue)
PassT::Result * getCachedResult(IRUnitT &IR) const
Get the cached result of an analysis pass for a given IR unit.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
bool removeUnreachableBlocks(Function &F, DomTreeUpdater *DTU=nullptr, MemorySSAUpdater *MSSAU=nullptr)
Remove all blocks that can not be reached from the function's entry.
bool isUnconditional() const
Analysis pass providing the TargetLibraryInfo.
INITIALIZE_PASS(LowerConstantIntrinsics, "lower-constant-intrinsics", "Lower constant intrinsics", false, false) FunctionPass *llvm
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
A container for analyses that lazily runs them and caches their results.
The header file for the LowerConstantIntrinsics pass as used by the new pass manager.
A wrapper class for inspecting calls to intrinsic functions.
const BasicBlock * getParent() const