45#define DEBUG_TYPE "scalarize-masked-mem-intrin"
49class ScalarizeMaskedMemIntrinLegacyPass :
public FunctionPass {
53 explicit ScalarizeMaskedMemIntrinLegacyPass() :
FunctionPass(ID) {
61 return "Scalarize Masked Memory Intrinsics";
80char ScalarizeMaskedMemIntrinLegacyPass::ID = 0;
83 "Scalarize unsupported masked memory intrinsics",
false,
88 "Scalarize unsupported masked memory intrinsics",
false,
92 return new ScalarizeMaskedMemIntrinLegacyPass();
101 for (
unsigned i = 0; i != NumElts; ++i) {
102 Constant *CElt =
C->getAggregateElement(i);
112 return DL.isBigEndian() ? VectorWidth - 1 - Idx : Idx;
116 unsigned SourcePtrOperand,
117 unsigned DestPtrOperand) {
118 MDNode *CacheHint = Source.getMetadata(LLVMContext::MD_mem_cache_hint);
124 if (OperandNo->getZExtValue() != SourcePtrOperand)
131 {DestOperandNo, CacheHint->getOperand(1)}));
136 unsigned SourcePtrOperand,
unsigned DestPtrOperand,
Type *AccessType,
137 bool IsWholeAccess, std::optional<size_t> ByteOffset) {
142 {LLVMContext::MD_nontemporal,
143 LLVMContext::MD_mem_parallel_loop_access,
144 LLVMContext::MD_access_group, LLVMContext::MD_annotation,
145 LLVMContext::MD_nosanitize, LLVMContext::MD_mmra});
147 AAMDNodes AANodes = Source.getAAMetadata();
164 unsigned SourcePtrOperand,
165 std::optional<size_t> ByteOffset) {
168 Dest.
getType() == Source.getType(), ByteOffset);
172 Dest.
copyMetadata(Source, {LLVMContext::MD_fpmath, LLVMContext::MD_range,
173 LLVMContext::MD_invariant_load});
179 unsigned SourcePtrOperand,
180 std::optional<size_t> ByteOffset) {
230 Type *EltTy = VecType->getElementType();
236 Builder.SetInsertPoint(InsertPt);
237 Builder.SetCurrentDebugLocation(CI->
getDebugLoc());
241 LoadInst *NewI = Builder.CreateAlignedLoad(VecType, Ptr, AlignVal);
251 const Align AdjustedAlignVal =
256 Value *VResult = Src0;
259 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
260 if (
cast<Constant>(Mask)->getAggregateElement(Idx)->isNullValue())
262 Value *Gep = Builder.CreateConstInBoundsGEP1_32(EltTy, Ptr, Idx);
263 LoadInst *
Load = Builder.CreateAlignedLoad(EltTy, Gep, AdjustedAlignVal);
266 Idx *
DL.getTypeAllocSize(EltTy).getFixedValue());
267 VResult = Builder.CreateInsertElement(VResult,
Load, Idx);
279 Mask->getName() +
".first");
289 CondBlock->
setName(
"cond.load");
291 LoadInst *
Load = Builder.CreateAlignedLoad(VecType, Ptr, AlignVal,
297 Builder.SetInsertPoint(PostLoad, PostLoad->
begin());
298 PHINode *Phi = Builder.CreatePHI(VecType, 2);
299 Phi->addIncoming(
Load, CondBlock);
300 Phi->addIncoming(Src0, IfBlock);
311 Value *SclrMask =
nullptr;
312 if (VectorWidth != 1 && !HasBranchDivergence) {
314 SclrMask = Builder.CreateBitCast(Mask, SclrMaskTy,
"scalar_mask");
317 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
328 if (SclrMask !=
nullptr) {
331 Predicate = Builder.CreateICmpNE(Builder.CreateAnd(SclrMask, Mask),
332 Builder.getIntN(VectorWidth, 0));
334 Predicate = Builder.CreateExtractElement(Mask, Idx);
352 CondBlock->
setName(
"cond.load");
355 Value *Gep = Builder.CreateConstInBoundsGEP1_32(EltTy, Ptr, Idx);
356 LoadInst *
Load = Builder.CreateAlignedLoad(EltTy, Gep, AdjustedAlignVal);
359 Idx *
DL.getTypeAllocSize(EltTy).getFixedValue());
360 Value *NewVResult = Builder.CreateInsertElement(VResult,
Load, Idx);
366 IfBlock = NewIfBlock;
369 Builder.SetInsertPoint(NewIfBlock, NewIfBlock->
begin());
370 PHINode *Phi = Builder.CreatePHI(VecType, 2,
"res.phi.else");
371 Phi->addIncoming(NewVResult, CondBlock);
372 Phi->addIncoming(VResult, PrevIfBlock);
418 Type *EltTy = VecType->getElementType();
422 Builder.SetInsertPoint(InsertPt);
423 Builder.SetCurrentDebugLocation(CI->
getDebugLoc());
427 StoreInst *
Store = Builder.CreateAlignedStore(Src, Ptr, AlignVal);
432 Store->copyMetadata(*CI, LLVMContext::MD_DIAssignID);
438 const Align AdjustedAlignVal =
443 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
444 if (
cast<Constant>(Mask)->getAggregateElement(Idx)->isNullValue())
446 Value *OneElt = Builder.CreateExtractElement(Src, Idx);
447 Value *Gep = Builder.CreateConstInBoundsGEP1_32(EltTy, Ptr, Idx);
449 Builder.CreateAlignedStore(OneElt, Gep, AdjustedAlignVal);
452 Idx *
DL.getTypeAllocSize(EltTy).getFixedValue());
463 Mask->getName() +
".first");
472 CondBlock->
setName(
"cond.store");
475 StoreInst *
Store = Builder.CreateAlignedStore(Src, Ptr, AlignVal);
480 Store->copyMetadata(*CI, LLVMContext::MD_DIAssignID);
490 Value *SclrMask =
nullptr;
491 if (VectorWidth != 1 && !HasBranchDivergence) {
493 SclrMask = Builder.CreateBitCast(Mask, SclrMaskTy,
"scalar_mask");
496 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
507 if (SclrMask !=
nullptr) {
510 Predicate = Builder.CreateICmpNE(Builder.CreateAnd(SclrMask, Mask),
511 Builder.getIntN(VectorWidth, 0));
513 Predicate = Builder.CreateExtractElement(Mask, Idx);
531 CondBlock->
setName(
"cond.store");
534 Value *OneElt = Builder.CreateExtractElement(Src, Idx);
535 Value *Gep = Builder.CreateConstInBoundsGEP1_32(EltTy, Ptr, Idx);
537 Builder.CreateAlignedStore(OneElt, Gep, AdjustedAlignVal);
540 Idx *
DL.getTypeAllocSize(EltTy).getFixedValue());
546 Builder.SetInsertPoint(NewIfBlock, NewIfBlock->
begin());
583 bool HasBranchDivergence,
CallInst *CI,
590 Type *EltTy = VecType->getElementType();
595 Builder.SetInsertPoint(InsertPt);
598 Builder.SetCurrentDebugLocation(CI->
getDebugLoc());
601 Value *VResult = Src0;
602 unsigned VectorWidth = VecType->getNumElements();
606 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
607 if (
cast<Constant>(Mask)->getAggregateElement(Idx)->isNullValue())
609 Value *Ptr = Builder.CreateExtractElement(Ptrs, Idx,
"Ptr" +
Twine(Idx));
611 Builder.CreateAlignedLoad(EltTy, Ptr, AlignVal,
"Load" +
Twine(Idx));
615 Builder.CreateInsertElement(VResult,
Load, Idx,
"Res" +
Twine(Idx));
625 Value *SclrMask =
nullptr;
626 if (VectorWidth != 1 && !HasBranchDivergence) {
628 SclrMask = Builder.CreateBitCast(Mask, SclrMaskTy,
"scalar_mask");
631 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
643 if (SclrMask !=
nullptr) {
646 Predicate = Builder.CreateICmpNE(Builder.CreateAnd(SclrMask, Mask),
647 Builder.getIntN(VectorWidth, 0));
649 Predicate = Builder.CreateExtractElement(Mask, Idx,
"Mask" +
Twine(Idx));
667 CondBlock->
setName(
"cond.load");
670 Value *Ptr = Builder.CreateExtractElement(Ptrs, Idx,
"Ptr" +
Twine(Idx));
672 Builder.CreateAlignedLoad(EltTy, Ptr, AlignVal,
"Load" +
Twine(Idx));
676 Builder.CreateInsertElement(VResult,
Load, Idx,
"Res" +
Twine(Idx));
682 IfBlock = NewIfBlock;
685 Builder.SetInsertPoint(NewIfBlock, NewIfBlock->
begin());
686 PHINode *Phi = Builder.CreatePHI(VecType, 2,
"res.phi.else");
687 Phi->addIncoming(NewVResult, CondBlock);
688 Phi->addIncoming(VResult, PrevIfBlock);
725 bool HasBranchDivergence,
CallInst *CI,
736 "Vector of pointers is expected in masked scatter intrinsic");
740 Builder.SetInsertPoint(InsertPt);
741 Builder.SetCurrentDebugLocation(CI->
getDebugLoc());
744 unsigned VectorWidth = SrcFVTy->getNumElements();
748 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
749 if (
cast<Constant>(Mask)->getAggregateElement(Idx)->isNullValue())
752 Builder.CreateExtractElement(Src, Idx,
"Elt" +
Twine(Idx));
753 Value *Ptr = Builder.CreateExtractElement(Ptrs, Idx,
"Ptr" +
Twine(Idx));
754 StoreInst *
Store = Builder.CreateAlignedStore(OneElt, Ptr, AlignVal);
765 Value *SclrMask =
nullptr;
766 if (VectorWidth != 1 && !HasBranchDivergence) {
768 SclrMask = Builder.CreateBitCast(Mask, SclrMaskTy,
"scalar_mask");
771 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
782 if (SclrMask !=
nullptr) {
785 Predicate = Builder.CreateICmpNE(Builder.CreateAnd(SclrMask, Mask),
786 Builder.getIntN(VectorWidth, 0));
788 Predicate = Builder.CreateExtractElement(Mask, Idx,
"Mask" +
Twine(Idx));
806 CondBlock->
setName(
"cond.store");
809 Value *OneElt = Builder.CreateExtractElement(Src, Idx,
"Elt" +
Twine(Idx));
810 Value *Ptr = Builder.CreateExtractElement(Ptrs, Idx,
"Ptr" +
Twine(Idx));
811 StoreInst *
Store = Builder.CreateAlignedStore(OneElt, Ptr, AlignVal);
820 Builder.SetInsertPoint(NewIfBlock, NewIfBlock->
begin());
828 bool HasBranchDivergence,
CallInst *CI,
837 Type *EltTy = VecType->getElementType();
843 Builder.SetInsertPoint(InsertPt);
844 Builder.SetCurrentDebugLocation(CI->
getDebugLoc());
846 unsigned VectorWidth = VecType->getNumElements();
849 Value *VResult = PassThru;
852 const Align AdjustedAlignment =
859 unsigned MemIndex = 0;
862 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
864 if (
cast<Constant>(Mask)->getAggregateElement(Idx)->isNullValue()) {
866 ShuffleMask[Idx] = Idx + VectorWidth;
869 Builder.CreateConstInBoundsGEP1_32(EltTy, Ptr, MemIndex);
871 EltTy, NewPtr, AdjustedAlignment,
"Load" +
Twine(Idx));
874 MemIndex *
DL.getTypeAllocSize(EltTy).getFixedValue());
876 ShuffleMask[Idx] = Idx;
879 VResult = Builder.CreateInsertElement(VResult, InsertElt, Idx,
882 VResult = Builder.CreateShuffleVector(VResult, PassThru, ShuffleMask);
891 Value *SclrMask =
nullptr;
892 if (VectorWidth != 1 && !HasBranchDivergence) {
894 SclrMask = Builder.CreateBitCast(Mask, SclrMaskTy,
"scalar_mask");
897 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
909 if (SclrMask !=
nullptr) {
912 Predicate = Builder.CreateICmpNE(Builder.CreateAnd(SclrMask, Mask),
913 Builder.getIntN(VectorWidth, 0));
915 Predicate = Builder.CreateExtractElement(Mask, Idx,
"Mask" +
Twine(Idx));
933 CondBlock->
setName(
"cond.load");
936 LoadInst *
Load = Builder.CreateAlignedLoad(EltTy, Ptr, AdjustedAlignment);
939 Value *NewVResult = Builder.CreateInsertElement(VResult,
Load, Idx);
943 if ((Idx + 1) != VectorWidth)
944 NewPtr = Builder.CreateConstInBoundsGEP1_32(EltTy, Ptr, 1);
950 IfBlock = NewIfBlock;
953 Builder.SetInsertPoint(NewIfBlock, NewIfBlock->
begin());
954 PHINode *ResultPhi = Builder.CreatePHI(VecType, 2,
"res.phi.else");
960 if ((Idx + 1) != VectorWidth) {
961 PHINode *PtrPhi = Builder.CreatePHI(Ptr->
getType(), 2,
"ptr.phi.else");
975 bool HasBranchDivergence,
CallInst *CI,
989 Builder.SetInsertPoint(InsertPt);
990 Builder.SetCurrentDebugLocation(CI->
getDebugLoc());
992 Type *EltTy = VecType->getElementType();
995 const Align AdjustedAlignment =
998 unsigned VectorWidth = VecType->getNumElements();
1002 unsigned MemIndex = 0;
1003 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
1004 if (
cast<Constant>(Mask)->getAggregateElement(Idx)->isNullValue())
1007 Builder.CreateExtractElement(Src, Idx,
"Elt" +
Twine(Idx));
1008 Value *NewPtr = Builder.CreateConstInBoundsGEP1_32(EltTy, Ptr, MemIndex);
1010 Builder.CreateAlignedStore(OneElt, NewPtr, AdjustedAlignment);
1013 MemIndex *
DL.getTypeAllocSize(EltTy).getFixedValue());
1023 Value *SclrMask =
nullptr;
1024 if (VectorWidth != 1 && !HasBranchDivergence) {
1026 SclrMask = Builder.CreateBitCast(Mask, SclrMaskTy,
"scalar_mask");
1029 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
1039 if (SclrMask !=
nullptr) {
1042 Predicate = Builder.CreateICmpNE(Builder.CreateAnd(SclrMask, Mask),
1043 Builder.getIntN(VectorWidth, 0));
1045 Predicate = Builder.CreateExtractElement(Mask, Idx,
"Mask" +
Twine(Idx));
1063 CondBlock->
setName(
"cond.store");
1066 Value *OneElt = Builder.CreateExtractElement(Src, Idx);
1068 Builder.CreateAlignedStore(OneElt, Ptr, AdjustedAlignment);
1074 if ((Idx + 1) != VectorWidth)
1075 NewPtr = Builder.CreateConstInBoundsGEP1_32(EltTy, Ptr, 1);
1081 IfBlock = NewIfBlock;
1083 Builder.SetInsertPoint(NewIfBlock, NewIfBlock->
begin());
1086 if ((Idx + 1) != VectorWidth) {
1087 PHINode *PtrPhi = Builder.CreatePHI(Ptr->
getType(), 2,
"ptr.phi.else");
1113 Builder.SetInsertPoint(InsertPt);
1115 Builder.SetCurrentDebugLocation(CI->
getDebugLoc());
1118 unsigned VectorWidth = AddrType->getNumElements();
1123 case Intrinsic::experimental_vector_histogram_add:
1124 UpdateOp = Builder.CreateAdd(
Load, Inc);
1126 case Intrinsic::experimental_vector_histogram_uadd_sat:
1128 Builder.CreateIntrinsic(Intrinsic::uadd_sat, {EltTy}, {
Load, Inc});
1130 case Intrinsic::experimental_vector_histogram_umin:
1131 UpdateOp = Builder.CreateIntrinsic(Intrinsic::umin, {EltTy}, {
Load, Inc});
1133 case Intrinsic::experimental_vector_histogram_umax:
1134 UpdateOp = Builder.CreateIntrinsic(Intrinsic::umax, {EltTy}, {
Load, Inc});
1145 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
1146 if (
cast<Constant>(Mask)->getAggregateElement(Idx)->isNullValue())
1148 Value *Ptr = Builder.CreateExtractElement(Ptrs, Idx,
"Ptr" +
Twine(Idx));
1163 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
1165 Builder.CreateExtractElement(Mask, Idx,
"Mask" +
Twine(Idx));
1176 CondBlock->
setName(
"cond.histogram.update");
1179 Value *Ptr = Builder.CreateExtractElement(Ptrs, Idx,
"Ptr" +
Twine(Idx));
1193 Builder.SetInsertPoint(NewIfBlock, NewIfBlock->
begin());
1202 std::optional<DomTreeUpdater> DTU;
1204 DTU.emplace(DT, DomTreeUpdater::UpdateStrategy::Lazy);
1206 bool EverMadeChange =
false;
1207 bool MadeChange =
true;
1208 auto &
DL =
F.getDataLayout();
1209 bool HasBranchDivergence =
TTI.hasBranchDivergence(&
F);
1210 while (MadeChange) {
1213 bool ModifiedDTOnIteration =
false;
1215 HasBranchDivergence, DTU ? &*DTU :
nullptr);
1218 if (ModifiedDTOnIteration)
1222 EverMadeChange |= MadeChange;
1224 return EverMadeChange;
1227bool ScalarizeMaskedMemIntrinLegacyPass::runOnFunction(
Function &
F) {
1228 auto &
TTI = getAnalysis<TargetTransformInfoWrapperPass>().getTTI(
F);
1229 DominatorTree *DT =
nullptr;
1230 if (
auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>())
1231 DT = &DTWP->getDomTree();
1250 bool MadeChange =
false;
1253 while (CurInstIterator != BB.
end()) {
1273 [](
Value *V) { return isa<ScalableVectorType>(V->getType()); }))
1275 switch (
II->getIntrinsicID()) {
1278 case Intrinsic::experimental_vector_histogram_add:
1279 case Intrinsic::experimental_vector_histogram_uadd_sat:
1280 case Intrinsic::experimental_vector_histogram_umin:
1281 case Intrinsic::experimental_vector_histogram_umax:
1287 case Intrinsic::masked_load:
1289 if (
TTI.isLegalMaskedLoad(
1292 ->getAddressSpace(),
1299 case Intrinsic::masked_store:
1300 if (
TTI.isLegalMaskedStore(
1304 ->getAddressSpace(),
1311 case Intrinsic::masked_gather: {
1314 if (
TTI.isLegalMaskedGather(LoadTy, Alignment) &&
1320 case Intrinsic::masked_scatter: {
1323 if (
TTI.isLegalMaskedScatter(StoreTy, Alignment) &&
1330 case Intrinsic::masked_expandload:
1331 if (
TTI.isLegalMaskedExpandLoad(
1333 CI->
getAttributes().getParamAttrs(0).getAlignment().valueOrOne()))
1337 case Intrinsic::masked_compressstore:
1338 if (
TTI.isLegalMaskedCompressStore(
1340 CI->
getAttributes().getParamAttrs(1).getAlignment().valueOrOne()))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static bool runImpl(MachineFunction &MF)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static bool runOnFunction(Function &F, bool PostInlining)
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
This file contains the declarations for profiling metadata utility functions.
static void scalarizeMaskedExpandLoad(const DataLayout &DL, bool HasBranchDivergence, CallInst *CI, DomTreeUpdater *DTU, bool &ModifiedDT)
static void scalarizeMaskedVectorHistogram(const DataLayout &DL, CallInst *CI, DomTreeUpdater *DTU, bool &ModifiedDT)
static void copyMemCacheHint(Instruction &Dest, const Instruction &Source, unsigned SourcePtrOperand, unsigned DestPtrOperand)
static void copyMetadataForScalarizedStore(StoreInst &Dest, const Instruction &Source, const DataLayout &DL, unsigned SourcePtrOperand, std::optional< size_t > ByteOffset)
static bool optimizeBlock(BasicBlock &BB, bool &ModifiedDT, const TargetTransformInfo &TTI, const DataLayout &DL, bool HasBranchDivergence, DomTreeUpdater *DTU)
static void scalarizeMaskedScatter(const DataLayout &DL, bool HasBranchDivergence, CallInst *CI, DomTreeUpdater *DTU, bool &ModifiedDT)
static unsigned adjustForEndian(const DataLayout &DL, unsigned VectorWidth, unsigned Idx)
static bool optimizeCallInst(CallInst *CI, bool &ModifiedDT, const TargetTransformInfo &TTI, const DataLayout &DL, bool HasBranchDivergence, DomTreeUpdater *DTU)
static void copyMetadataForScalarizedLoad(LoadInst &Dest, const Instruction &Source, const DataLayout &DL, unsigned SourcePtrOperand, std::optional< size_t > ByteOffset)
static void scalarizeMaskedStore(const DataLayout &DL, bool HasBranchDivergence, CallInst *CI, DomTreeUpdater *DTU, bool &ModifiedDT)
static void scalarizeMaskedCompressStore(const DataLayout &DL, bool HasBranchDivergence, CallInst *CI, DomTreeUpdater *DTU, bool &ModifiedDT)
static void scalarizeMaskedGather(const DataLayout &DL, bool HasBranchDivergence, CallInst *CI, DomTreeUpdater *DTU, bool &ModifiedDT)
static void copyMetadataForMemoryAccess(Instruction &Dest, const Instruction &Source, const DataLayout &DL, unsigned SourcePtrOperand, unsigned DestPtrOperand, Type *AccessType, bool IsWholeAccess, std::optional< size_t > ByteOffset)
static bool runImpl(Function &F, const TargetTransformInfo &TTI, DominatorTree *DT)
static bool isConstantIntVector(Value *Mask)
static void scalarizeMaskedLoad(const DataLayout &DL, bool HasBranchDivergence, CallInst *CI, DomTreeUpdater *DTU, bool &ModifiedDT)
static APInt getOneBitSet(unsigned numBits, unsigned BitNo)
Return an APInt with exactly one bit set in the result.
PassT::Result * getCachedResult(IRUnitT &IR) const
Get the cached result of an analysis pass for a given IR unit.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
LLVM Basic Block Representation.
iterator begin()
Instruction iterator methods.
InstListType::iterator iterator
Instruction iterators...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
MaybeAlign getParamAlign(unsigned ArgNo) const
Extract the alignment for a call or parameter (0=unknown).
Value * getArgOperand(unsigned i) const
LLVM_ABI Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
AttributeList getAttributes() const
Return the attributes for this call.
This class represents a function call, abstracting a target machine's calling convention.
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
Analysis pass which computes a DominatorTree.
Legacy analysis pass which computes a DominatorTree.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
FunctionPass class - This class is used to implement most global optimizations.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
LLVM_ABI void setAAMetadata(const AAMDNodes &N)
Sets the AA metadata on this instruction from the AAMDNodes structure.
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
LLVM_ABI BasicBlock * getSuccessor(unsigned Idx) const LLVM_READONLY
Return the specified successor. This instruction must be a terminator.
LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
LLVM_ABI void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
A wrapper class for inspecting calls to intrinsic functions.
An instruction for reading from memory.
static unsigned getPointerOperandIndex()
const MDOperand & getOperand(unsigned I) const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
unsigned getNumOperands() const
Return number of MDNode operands.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
static LLVM_ABI PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserve()
Mark an analysis as preserved.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
Value * getValueOperand()
static unsigned getPointerOperandIndex()
Represent a constant reference to a string, i.e.
Analysis pass providing the TargetTransformInfo.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
LLVM_ABI TypeSize getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
bool isVoidTy() const
Return true if this is 'void'.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI void setName(const Twine &Name)
Change the name of the value.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVMContext & getContext() const
All values hold a context through their type.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
LLVM_ABI void takeName(Value *V)
Transfer the name from V to this value.
const ParentTy * getParent() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
@ Load
The value being inserted comes from a load (InsertElement only).
@ Store
The extracted value is stored (ExtractElement only).
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
LLVM_ABI FunctionPass * createScalarizeMaskedMemIntrinLegacyPass()
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI bool isSplatValue(const Value *V, int Index=-1, unsigned Depth=0)
Return true if each element of the vector value V is poisoned or equal to every other non-poisoned el...
LLVM_ABI void initializeScalarizeMaskedMemIntrinLegacyPassPass(PassRegistry &)
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI MDNode * getExplicitlyUnknownBranchWeightsIfProfiled(Function &F, StringRef PassName)
Returns a metadata node containing unknown branch weights if the function has an entry count,...
constexpr int PoisonMaskElem
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
Align commonAlignment(Align A, uint64_t Offset)
Returns the alignment that satisfies both alignments.
LLVM_ABI Instruction * SplitBlockAndInsertIfThen(Value *Cond, BasicBlock::iterator SplitBefore, bool Unreachable, MDNode *BranchWeights=nullptr, DomTreeUpdater *DTU=nullptr, LoopInfo *LI=nullptr, BasicBlock *ThenBlock=nullptr)
Split the containing block at the specified instruction - everything before SplitBefore stays in the ...
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
MDNode * TBAAStruct
The tag for type-based alias analysis (tbaa struct).
LLVM_ABI AAMDNodes adjustForAccess(unsigned AccessSize)
Create a new AAMDNode for accessing AccessSize bytes of this AAMDNode.
This struct is a compact representation of a valid (non-zero power of two) alignment.
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.
LLVM_ABI PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)