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();
238 LoadInst *NewI = Builder.CreateAlignedLoad(VecType, Ptr, AlignVal);
248 const Align AdjustedAlignVal =
253 Value *VResult = Src0;
256 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
257 if (
cast<Constant>(Mask)->getAggregateElement(Idx)->isNullValue())
259 Value *Gep = Builder.CreateConstInBoundsGEP1_32(EltTy, Ptr, Idx);
260 LoadInst *
Load = Builder.CreateAlignedLoad(EltTy, Gep, AdjustedAlignVal);
263 Idx *
DL.getTypeAllocSize(EltTy).getFixedValue());
264 VResult = Builder.CreateInsertElement(VResult,
Load, Idx);
276 Mask->getName() +
".first");
286 CondBlock->
setName(
"cond.load");
288 LoadInst *
Load = Builder.CreateAlignedLoad(VecType, Ptr, AlignVal,
294 Builder.SetInsertPoint(PostLoad, PostLoad->
begin());
295 PHINode *Phi = Builder.CreatePHI(VecType, 2);
296 Phi->addIncoming(
Load, CondBlock);
297 Phi->addIncoming(Src0, IfBlock);
308 Value *SclrMask =
nullptr;
309 if (VectorWidth != 1 && !HasBranchDivergence) {
311 SclrMask = Builder.CreateBitCast(Mask, SclrMaskTy,
"scalar_mask");
314 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
325 if (SclrMask !=
nullptr) {
328 Predicate = Builder.CreateICmpNE(Builder.CreateAnd(SclrMask, Mask),
329 Builder.getIntN(VectorWidth, 0));
331 Predicate = Builder.CreateExtractElement(Mask, Idx);
349 CondBlock->
setName(
"cond.load");
352 Value *Gep = Builder.CreateConstInBoundsGEP1_32(EltTy, Ptr, Idx);
353 LoadInst *
Load = Builder.CreateAlignedLoad(EltTy, Gep, AdjustedAlignVal);
356 Idx *
DL.getTypeAllocSize(EltTy).getFixedValue());
357 Value *NewVResult = Builder.CreateInsertElement(VResult,
Load, Idx);
363 IfBlock = NewIfBlock;
366 Builder.SetInsertPoint(NewIfBlock, NewIfBlock->
begin());
367 PHINode *Phi = Builder.CreatePHI(VecType, 2,
"res.phi.else");
368 Phi->addIncoming(NewVResult, CondBlock);
369 Phi->addIncoming(VResult, PrevIfBlock);
415 Type *EltTy = VecType->getElementType();
422 StoreInst *
Store = Builder.CreateAlignedStore(Src, Ptr, AlignVal);
427 Store->copyMetadata(*CI, LLVMContext::MD_DIAssignID);
433 const Align AdjustedAlignVal =
438 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
439 if (
cast<Constant>(Mask)->getAggregateElement(Idx)->isNullValue())
441 Value *OneElt = Builder.CreateExtractElement(Src, Idx);
442 Value *Gep = Builder.CreateConstInBoundsGEP1_32(EltTy, Ptr, Idx);
444 Builder.CreateAlignedStore(OneElt, Gep, AdjustedAlignVal);
447 Idx *
DL.getTypeAllocSize(EltTy).getFixedValue());
458 Mask->getName() +
".first");
467 CondBlock->
setName(
"cond.store");
470 StoreInst *
Store = Builder.CreateAlignedStore(Src, Ptr, AlignVal);
475 Store->copyMetadata(*CI, LLVMContext::MD_DIAssignID);
485 Value *SclrMask =
nullptr;
486 if (VectorWidth != 1 && !HasBranchDivergence) {
488 SclrMask = Builder.CreateBitCast(Mask, SclrMaskTy,
"scalar_mask");
491 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
502 if (SclrMask !=
nullptr) {
505 Predicate = Builder.CreateICmpNE(Builder.CreateAnd(SclrMask, Mask),
506 Builder.getIntN(VectorWidth, 0));
508 Predicate = Builder.CreateExtractElement(Mask, Idx);
526 CondBlock->
setName(
"cond.store");
529 Value *OneElt = Builder.CreateExtractElement(Src, Idx);
530 Value *Gep = Builder.CreateConstInBoundsGEP1_32(EltTy, Ptr, Idx);
532 Builder.CreateAlignedStore(OneElt, Gep, AdjustedAlignVal);
535 Idx *
DL.getTypeAllocSize(EltTy).getFixedValue());
541 Builder.SetInsertPoint(NewIfBlock, NewIfBlock->
begin());
578 bool HasBranchDivergence,
CallInst *CI,
585 Type *EltTy = VecType->getElementType();
593 Value *VResult = Src0;
594 unsigned VectorWidth = VecType->getNumElements();
598 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
599 if (
cast<Constant>(Mask)->getAggregateElement(Idx)->isNullValue())
601 Value *Ptr = Builder.CreateExtractElement(Ptrs, Idx,
"Ptr" +
Twine(Idx));
603 Builder.CreateAlignedLoad(EltTy, Ptr, AlignVal,
"Load" +
Twine(Idx));
607 Builder.CreateInsertElement(VResult,
Load, Idx,
"Res" +
Twine(Idx));
617 Value *SclrMask =
nullptr;
618 if (VectorWidth != 1 && !HasBranchDivergence) {
620 SclrMask = Builder.CreateBitCast(Mask, SclrMaskTy,
"scalar_mask");
623 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
635 if (SclrMask !=
nullptr) {
638 Predicate = Builder.CreateICmpNE(Builder.CreateAnd(SclrMask, Mask),
639 Builder.getIntN(VectorWidth, 0));
641 Predicate = Builder.CreateExtractElement(Mask, Idx,
"Mask" +
Twine(Idx));
659 CondBlock->
setName(
"cond.load");
662 Value *Ptr = Builder.CreateExtractElement(Ptrs, Idx,
"Ptr" +
Twine(Idx));
664 Builder.CreateAlignedLoad(EltTy, Ptr, AlignVal,
"Load" +
Twine(Idx));
668 Builder.CreateInsertElement(VResult,
Load, Idx,
"Res" +
Twine(Idx));
674 IfBlock = NewIfBlock;
677 Builder.SetInsertPoint(NewIfBlock, NewIfBlock->
begin());
678 PHINode *Phi = Builder.CreatePHI(VecType, 2,
"res.phi.else");
679 Phi->addIncoming(NewVResult, CondBlock);
680 Phi->addIncoming(VResult, PrevIfBlock);
717 bool HasBranchDivergence,
CallInst *CI,
728 "Vector of pointers is expected in masked scatter intrinsic");
734 unsigned VectorWidth = SrcFVTy->getNumElements();
738 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
739 if (
cast<Constant>(Mask)->getAggregateElement(Idx)->isNullValue())
742 Builder.CreateExtractElement(Src, Idx,
"Elt" +
Twine(Idx));
743 Value *Ptr = Builder.CreateExtractElement(Ptrs, Idx,
"Ptr" +
Twine(Idx));
744 StoreInst *
Store = Builder.CreateAlignedStore(OneElt, Ptr, AlignVal);
755 Value *SclrMask =
nullptr;
756 if (VectorWidth != 1 && !HasBranchDivergence) {
758 SclrMask = Builder.CreateBitCast(Mask, SclrMaskTy,
"scalar_mask");
761 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
772 if (SclrMask !=
nullptr) {
775 Predicate = Builder.CreateICmpNE(Builder.CreateAnd(SclrMask, Mask),
776 Builder.getIntN(VectorWidth, 0));
778 Predicate = Builder.CreateExtractElement(Mask, Idx,
"Mask" +
Twine(Idx));
796 CondBlock->
setName(
"cond.store");
799 Value *OneElt = Builder.CreateExtractElement(Src, Idx,
"Elt" +
Twine(Idx));
800 Value *Ptr = Builder.CreateExtractElement(Ptrs, Idx,
"Ptr" +
Twine(Idx));
801 StoreInst *
Store = Builder.CreateAlignedStore(OneElt, Ptr, AlignVal);
810 Builder.SetInsertPoint(NewIfBlock, NewIfBlock->
begin());
818 bool HasBranchDivergence,
CallInst *CI,
827 Type *EltTy = VecType->getElementType();
833 unsigned VectorWidth = VecType->getNumElements();
836 Value *VResult = PassThru;
839 const Align AdjustedAlignment =
846 unsigned MemIndex = 0;
849 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
851 if (
cast<Constant>(Mask)->getAggregateElement(Idx)->isNullValue()) {
853 ShuffleMask[Idx] = Idx + VectorWidth;
856 Builder.CreateConstInBoundsGEP1_32(EltTy, Ptr, MemIndex);
858 EltTy, NewPtr, AdjustedAlignment,
"Load" +
Twine(Idx));
861 MemIndex *
DL.getTypeAllocSize(EltTy).getFixedValue());
863 ShuffleMask[Idx] = Idx;
866 VResult = Builder.CreateInsertElement(VResult, InsertElt, Idx,
869 VResult = Builder.CreateShuffleVector(VResult, PassThru, ShuffleMask);
878 Value *SclrMask =
nullptr;
879 if (VectorWidth != 1 && !HasBranchDivergence) {
881 SclrMask = Builder.CreateBitCast(Mask, SclrMaskTy,
"scalar_mask");
884 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
896 if (SclrMask !=
nullptr) {
899 Predicate = Builder.CreateICmpNE(Builder.CreateAnd(SclrMask, Mask),
900 Builder.getIntN(VectorWidth, 0));
902 Predicate = Builder.CreateExtractElement(Mask, Idx,
"Mask" +
Twine(Idx));
920 CondBlock->
setName(
"cond.load");
923 LoadInst *
Load = Builder.CreateAlignedLoad(EltTy, Ptr, AdjustedAlignment);
926 Value *NewVResult = Builder.CreateInsertElement(VResult,
Load, Idx);
930 if ((Idx + 1) != VectorWidth)
931 NewPtr = Builder.CreateConstInBoundsGEP1_32(EltTy, Ptr, 1);
937 IfBlock = NewIfBlock;
940 Builder.SetInsertPoint(NewIfBlock, NewIfBlock->
begin());
941 PHINode *ResultPhi = Builder.CreatePHI(VecType, 2,
"res.phi.else");
947 if ((Idx + 1) != VectorWidth) {
948 PHINode *PtrPhi = Builder.CreatePHI(Ptr->
getType(), 2,
"ptr.phi.else");
962 bool HasBranchDivergence,
CallInst *CI,
976 Type *EltTy = VecType->getElementType();
979 const Align AdjustedAlignment =
982 unsigned VectorWidth = VecType->getNumElements();
986 unsigned MemIndex = 0;
987 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
988 if (
cast<Constant>(Mask)->getAggregateElement(Idx)->isNullValue())
991 Builder.CreateExtractElement(Src, Idx,
"Elt" +
Twine(Idx));
992 Value *NewPtr = Builder.CreateConstInBoundsGEP1_32(EltTy, Ptr, MemIndex);
994 Builder.CreateAlignedStore(OneElt, NewPtr, AdjustedAlignment);
997 MemIndex *
DL.getTypeAllocSize(EltTy).getFixedValue());
1007 Value *SclrMask =
nullptr;
1008 if (VectorWidth != 1 && !HasBranchDivergence) {
1010 SclrMask = Builder.CreateBitCast(Mask, SclrMaskTy,
"scalar_mask");
1013 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
1023 if (SclrMask !=
nullptr) {
1026 Predicate = Builder.CreateICmpNE(Builder.CreateAnd(SclrMask, Mask),
1027 Builder.getIntN(VectorWidth, 0));
1029 Predicate = Builder.CreateExtractElement(Mask, Idx,
"Mask" +
Twine(Idx));
1047 CondBlock->
setName(
"cond.store");
1050 Value *OneElt = Builder.CreateExtractElement(Src, Idx);
1052 Builder.CreateAlignedStore(OneElt, Ptr, AdjustedAlignment);
1058 if ((Idx + 1) != VectorWidth)
1059 NewPtr = Builder.CreateConstInBoundsGEP1_32(EltTy, Ptr, 1);
1065 IfBlock = NewIfBlock;
1067 Builder.SetInsertPoint(NewIfBlock, NewIfBlock->
begin());
1070 if ((Idx + 1) != VectorWidth) {
1071 PHINode *PtrPhi = Builder.CreatePHI(Ptr->
getType(), 2,
"ptr.phi.else");
1099 unsigned VectorWidth = AddrType->getNumElements();
1104 case Intrinsic::experimental_vector_histogram_add:
1105 UpdateOp = Builder.CreateAdd(
Load, Inc);
1107 case Intrinsic::experimental_vector_histogram_uadd_sat:
1109 Builder.CreateIntrinsic(Intrinsic::uadd_sat, {EltTy}, {
Load, Inc});
1111 case Intrinsic::experimental_vector_histogram_umin:
1112 UpdateOp = Builder.CreateIntrinsic(Intrinsic::umin, {EltTy}, {
Load, Inc});
1114 case Intrinsic::experimental_vector_histogram_umax:
1115 UpdateOp = Builder.CreateIntrinsic(Intrinsic::umax, {EltTy}, {
Load, Inc});
1126 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
1127 if (
cast<Constant>(Mask)->getAggregateElement(Idx)->isNullValue())
1129 Value *Ptr = Builder.CreateExtractElement(Ptrs, Idx,
"Ptr" +
Twine(Idx));
1144 for (
unsigned Idx = 0; Idx < VectorWidth; ++Idx) {
1146 Builder.CreateExtractElement(Mask, Idx,
"Mask" +
Twine(Idx));
1157 CondBlock->
setName(
"cond.histogram.update");
1160 Value *Ptr = Builder.CreateExtractElement(Ptrs, Idx,
"Ptr" +
Twine(Idx));
1174 Builder.SetInsertPoint(NewIfBlock, NewIfBlock->
begin());
1183 std::optional<DomTreeUpdater> DTU;
1185 DTU.emplace(DT, DomTreeUpdater::UpdateStrategy::Lazy);
1187 bool EverMadeChange =
false;
1188 bool MadeChange =
true;
1189 auto &
DL =
F.getDataLayout();
1190 bool HasBranchDivergence =
TTI.hasBranchDivergence(&
F);
1191 while (MadeChange) {
1194 bool ModifiedDTOnIteration =
false;
1196 HasBranchDivergence, DTU ? &*DTU :
nullptr);
1199 if (ModifiedDTOnIteration)
1203 EverMadeChange |= MadeChange;
1205 return EverMadeChange;
1208bool ScalarizeMaskedMemIntrinLegacyPass::runOnFunction(
Function &
F) {
1209 auto &
TTI = getAnalysis<TargetTransformInfoWrapperPass>().getTTI(
F);
1210 DominatorTree *DT =
nullptr;
1211 if (
auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>())
1212 DT = &DTWP->getDomTree();
1231 bool MadeChange =
false;
1234 while (CurInstIterator != BB.
end()) {
1254 [](
Value *V) { return isa<ScalableVectorType>(V->getType()); }))
1256 switch (
II->getIntrinsicID()) {
1259 case Intrinsic::experimental_vector_histogram_add:
1260 case Intrinsic::experimental_vector_histogram_uadd_sat:
1261 case Intrinsic::experimental_vector_histogram_umin:
1262 case Intrinsic::experimental_vector_histogram_umax:
1268 case Intrinsic::masked_load:
1270 if (
TTI.isLegalMaskedLoad(
1273 ->getAddressSpace(),
1280 case Intrinsic::masked_store:
1281 if (
TTI.isLegalMaskedStore(
1285 ->getAddressSpace(),
1292 case Intrinsic::masked_gather: {
1295 if (
TTI.isLegalMaskedGather(LoadTy, Alignment) &&
1301 case Intrinsic::masked_scatter: {
1304 if (
TTI.isLegalMaskedScatter(StoreTy, Alignment) &&
1311 case Intrinsic::masked_expandload:
1312 if (
TTI.isLegalMaskedExpandLoad(
1314 CI->
getAttributes().getParamAttrs(0).getAlignment().valueOrOne()))
1318 case Intrinsic::masked_compressstore:
1319 if (
TTI.isLegalMaskedCompressStore(
1321 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...
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)