Go to the documentation of this file.
38 #define DEBUG_TYPE "lower-is-constant-intrinsic"
41 "Number of 'is.constant' intrinsic calls handled");
43 "Number of 'objectsize' intrinsic calls handled");
46 if (
auto *
C = dyn_cast<Constant>(II->
getOperand(0)))
47 if (
C->isManifestConstant())
55 bool HasDeadBlocks =
false;
63 UnsimplifiedUsers.
end());
65 for (
auto &VH : Worklist) {
66 BranchInst *BI = dyn_cast_or_null<BranchInst>(VH);
103 bool HasDeadBlocks =
false;
104 const auto &
DL =
F.getParent()->getDataLayout();
116 case Intrinsic::is_constant:
117 case Intrinsic::objectsize:
136 case Intrinsic::is_constant:
138 IsConstantIntrinsicsHandled++;
140 case Intrinsic::objectsize:
142 ObjectSizeIntrinsicsHandled++;
150 return !Worklist.empty();
180 getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(
F);
182 if (
auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>())
183 DT = &DTWP->getDomTree();
197 "Lower constant intrinsics",
false,
false)
204 return new LowerConstantIntrinsics();
A set of analyses that are preserved following a run of a transformation pass.
we should consider alternate ways to model stack dependencies Lots of things could be done in WebAssemblyTargetTransformInfo cpp there are numerous optimization related hooks that can be overridden in WebAssemblyTargetLowering Instead of the OptimizeReturned which should consider preserving the returned attribute through to MachineInstrs and extending the MemIntrinsicResults pass to do this optimization on calls too That would also let the WebAssemblyPeephole pass clean up dead defs for such as it does for stores Consider implementing and or getMachineCombinerPatterns Find a clean way to fix the problem which leads to the Shrink Wrapping pass being run after the WebAssembly PEI pass When setting multiple variables to the same constant
This is an optimization pass for GlobalISel generic memory operations.
Value handle that is nullable, but tries to track the Value.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
void applyUpdates(ArrayRef< DominatorTree::UpdateType > Updates)
Submit updates to all available trees.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
Target - Wrapper for Target specific information.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
bool removeUnreachableBlocks(Function &F, DomTreeUpdater *DTU=nullptr, MemorySSAUpdater *MSSAU=nullptr)
Remove all blocks that can not be reached from the function's entry.
static bool lowerConstantIntrinsics(Function &F, const TargetLibraryInfo &TLI, DominatorTree *DT)
LLVM Basic Block Representation.
constexpr const T * getPointer() const
constexpr bool hasValue() const
iterator begin()
Get an iterator to the beginning of the SetVector.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
bool match(Val *V, const Pattern &P)
(vector float) vec_cmpeq(*A, *B) C
static Value * lowerIsConstantIntrinsic(IntrinsicInst *II)
Represent the analysis usage information of a pass.
Legacy analysis pass which computes a DominatorTree.
STATISTIC(NumFunctions, "Total number of functions")
PreservedAnalyses run(Function &F, FunctionAnalysisManager &)
Run the pass over the function.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
is_zero m_Zero()
Match any null constant or a vector with all elements equal to 0.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
INITIALIZE_PASS_BEGIN(LowerConstantIntrinsics, "lower-constant-intrinsics", "Lower constant intrinsics", false, false) INITIALIZE_PASS_END(LowerConstantIntrinsics
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
void preserve()
Mark an analysis as preserved.
lower constant intrinsics
void emplace(ArgTypes &&... Args)
Create a new object by constructing it in place with the given arguments.
static BranchInst * Create(BasicBlock *IfTrue, Instruction *InsertBefore=nullptr)
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.
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.
static bool replaceConditionalBranchesOnConstant(Instruction *II, Value *NewValue, DomTreeUpdater *DTU)
bool isUnconditional() const
Type * getType() const
All values are typed, get the type of this value.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
bool pred_empty(const BasicBlock *BB)
static ConstantInt * getFalse(LLVMContext &Context)
static bool runOnFunction(Function &F, bool PostInlining)
static ConstantInt * getTrue(LLVMContext &Context)
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void initializeLowerConstantIntrinsicsPass(PassRegistry &)
PassT::Result * getCachedResult(IRUnitT &IR) const
Get the cached result of an analysis pass for a given IR unit.
Provides information about what library functions are available for the current target.
A wrapper class for inspecting calls to intrinsic functions.
Analysis pass which computes a DominatorTree.
iterator end()
Get an iterator to the end of the SetVector.
FunctionPass * createLowerConstantIntrinsicsPass()
const BasicBlock * getParent() const
Legacy wrapper pass to provide the GlobalsAAResult object.
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.
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()
Value * getOperand(unsigned i) const
Conditional or Unconditional Branch instruction.
LLVM Value Representation.
Analysis pass providing the TargetLibraryInfo.
BasicBlock * getSuccessor(unsigned i) const
static constexpr UpdateKind Delete
Optional< std::vector< StOtherPiece > > Other