69#define DEBUG_TYPE "expand-variadics"
80class VariadicABIInfo {
82 VariadicABIInfo() =
default;
85 static std::unique_ptr<VariadicABIInfo> create(
const Triple &
T);
88 virtual bool enableForTarget() = 0;
93 virtual bool vaListPassedInSSARegister() = 0;
99 virtual Type *vaListParameterType(
Module &M) = 0;
108 struct VAArgSlotInfo {
115 bool vaEndIsNop() {
return true; }
116 bool vaCopyIsMemcpy() {
return true; }
119 virtual bool ignoreFunction(
const Function *
F) {
return false; }
127 virtual ~VariadicABIInfo() =
default;
142 std::unique_ptr<VariadicABIInfo> ABI;
149 FAM->clear(*
F,
F->getName());
150 F->eraseFromParent();
153 StringRef getPassName()
const override {
return "Expand variadic functions"; }
157 template <
typename T>
bool isValidCallingConv(
T *
F) {
162 bool runOnModule(
Module &M)
override;
184 template <Intrinsic::ID ID,
typename InstructionType>
193 Changed |= expandVAIntrinsicCall(Builder,
DL,
I);
202 unsigned Addrspace) {
203 auto &Ctx = M.getContext();
208 Changed |= expandIntrinsicUsers<Intrinsic::vastart, VAStartInst>(
209 M, Builder, IntrinsicArgType);
210 Changed |= expandIntrinsicUsers<Intrinsic::vaend, VAEndInst>(
211 M, Builder, IntrinsicArgType);
212 Changed |= expandIntrinsicUsers<Intrinsic::vacopy, VACopyInst>(
213 M, Builder, IntrinsicArgType);
233 ArgTypes.
push_back(ABI->vaListParameterType(M));
238 return inlinableVariadicFunctionType(M, FTy, FTy->getReturnType());
242 if (
F->isIntrinsic() || !
F->isVarArg() ||
243 F->hasFnAttribute(Attribute::Naked))
246 if (ABI->ignoreFunction(
F))
249 if (!isValidCallingConv(
F))
255 if (!
F->hasExactDefinition())
261 bool expansionApplicableToFunctionCall(
CallBase *CB) {
263 if (CI->isMustTailCall()) {
268 if (!isValidCallingConv(CI))
283 class ExpandedCallFrame {
289 enum Tag {
Store, Memcpy, Padding };
294 Source.push_back({
V, Bytes, tag});
308 size_t size()
const {
return FieldTypes.
size(); }
309 bool empty()
const {
return FieldTypes.
empty(); }
312 const bool IsPacked =
true;
314 (
Twine(Name) +
".vararg").str(), IsPacked);
320 for (
size_t I = 0;
I <
size();
I++) {
322 auto [
V, bytes, tag] = Source[
I];
324 if (tag == Padding) {
329 auto Dst = Builder.CreateStructGEP(VarargsTy, Alloced,
I);
334 Builder.CreateStore(
V, Dst);
337 Builder.CreateMemCpy(Dst, {},
V, {}, bytes);
343bool ExpandVariadics::runOnModule(
Module &M) {
353 Triple TT(M.getTargetTriple());
354 ABI = VariadicABIInfo::create(TT);
358 if (!HasOverride && !ABI->enableForTarget())
363 Builder.disableGEPCanonicalization();
377 unsigned Addrspace = 0;
378 Changed |= expandVAIntrinsicUsersWithAddrspace(M, Builder, Addrspace);
380 Addrspace =
DL.getAllocaAddrSpace();
382 Changed |= expandVAIntrinsicUsersWithAddrspace(M, Builder, Addrspace);
386 ABI->getTargetSpecificVaIntrinAddrSpaces();
387 for (
unsigned TargetAS : TargetASVec) {
388 if (TargetAS == 0 || TargetAS ==
DL.getAllocaAddrSpace())
390 Changed |= expandVAIntrinsicUsersWithAddrspace(M, Builder, TargetAS);
398 if (
F.isDeclaration())
408 Changed |= expandVAArgInst(Builder,
DL, VA);
410 if (CB->isIndirectCall()) {
413 Changed |= expandCall(M, Builder, CB, FTy,
nullptr);
425 if (!expansionApplicableToFunction(M, OriginalFunction))
428 [[maybe_unused]]
const bool OriginalFunctionIsDeclaration =
430 assert(rewriteABI() || !OriginalFunctionIsDeclaration);
434 replaceAllUsesWithNewDeclaration(M, OriginalFunction);
441 deriveFixedArityReplacement(M, Builder, OriginalFunction);
444 OriginalFunctionIsDeclaration);
448 [[maybe_unused]]
Function *VariadicWrapperDefine =
449 defineVariadicWrapper(M, Builder, VariadicWrapper, FixedArityReplacement);
450 assert(VariadicWrapperDefine == VariadicWrapper);
457 LLVMContext::MD_prof,
458 FixedArityReplacement->
getMetadata(LLVMContext::MD_prof));
468 Value *CalledOperand = CB->getCalledOperand();
469 if (VariadicWrapper == CalledOperand)
471 FixedArityReplacement);
479 Function *
const ExternallyAccessible =
480 rewriteABI() ? FixedArityReplacement : VariadicWrapper;
482 rewriteABI() ? VariadicWrapper : FixedArityReplacement;
488 ExternallyAccessible->
takeName(OriginalFunction);
495 eraseFunction(OriginalFunction);
503 eraseFunction(VariadicWrapper);
510ExpandVariadics::replaceAllUsesWithNewDeclaration(
Module &M,
517 NF->
setName(
F.getName() +
".varargs");
519 F.getParent()->getFunctionList().insert(
F.getIterator(), NF);
521 AttrBuilder ParamAttrs(Ctx);
523 Attrs = Attrs.addParamAttributes(Ctx, FTy->getNumParams(), ParamAttrs);
539 assert(expansionApplicableToFunction(M, &
F));
541 auto &Ctx = M.getContext();
545 const bool FunctionIsDefinition = !
F.isDeclaration();
549 ArgTypes.
push_back(ABI->vaListParameterType(M));
551 FunctionType *NFTy = inlinableVariadicFunctionType(M, FTy);
557 F.getParent()->getFunctionList().insert(
F.getIterator(), NF);
558 NF->
setName(
F.getName() +
".valist");
560 AttrBuilder ParamAttrs(Ctx);
563 Attrs = Attrs.addParamAttributes(Ctx, NFTy->getNumParams() - 1, ParamAttrs);
567 if (FunctionIsDefinition) {
572 Arg.replaceAllUsesWith(NewArg);
573 NewArg->setName(Arg.getName());
580 F.getAllMetadata(MDs);
581 for (
auto [KindID,
Node] : MDs)
598 Type *VaListTy = ABI->vaListType(Ctx);
601 Builder.SetInsertPoint(BB);
604 Builder.CreateAlloca(VaListTy,
nullptr,
"va_start");
606 Builder.CreateLifetimeStart(VaListInstance);
608 Builder.CreateIntrinsic(Intrinsic::vastart, {
DL.getAllocaPtrType(Ctx)},
613 Value *VaListValue = VaListInstance;
614 if (ABI->vaListPassedInSSARegister())
615 VaListValue = Builder.CreateLoad(VaListTy, VaListInstance);
617 Type *ParameterType = ABI->vaListParameterType(M);
618 Args.push_back(Builder.CreateAddrSpaceCast(VaListValue, ParameterType));
620 CallInst *Result = Builder.CreateCall(FixedArityReplacement, Args);
622 Builder.CreateIntrinsic(Intrinsic::vaend, {
DL.getAllocaPtrType(Ctx)},
624 Builder.CreateLifetimeEnd(VaListInstance);
626 if (Result->getType()->isVoidTy())
627 Builder.CreateRetVoid();
629 Builder.CreateRet(Result);
631 return VariadicWrapper;
643 if (!expansionApplicableToFunctionCall(CB)) {
658 Align MaxFieldAlign(1);
668 ExpandedCallFrame Frame;
672 for (
unsigned I :
seq(VarargFunctionType->getNumParams(), CB->
arg_size())) {
683 DL.getTypeAllocSize(UnderlyingType).getFixedValue();
686 Type *FrameFieldType = UnderlyingType;
689 Value *SourceValue = ArgVal;
691 VariadicABIInfo::VAArgSlotInfo SlotInfo = ABI->slotInfo(
DL, UnderlyingType);
693 if (SlotInfo.Indirect) {
696 Builder.SetInsertPointPastAllocas(CBF);
697 Builder.SetCurrentDebugLocation(CB->
getDebugLoc());
699 Builder.CreateAlloca(UnderlyingType,
nullptr,
"IndirectAlloca");
701 Builder.SetInsertPoint(CB);
703 Builder.CreateMemCpy(CallerCopy, {}, ArgVal, {}, UnderlyingSize);
705 Builder.CreateStore(ArgVal, CallerCopy);
708 FrameFieldType =
DL.getAllocaPtrType(Ctx);
709 SourceValue = CallerCopy;
714 Align DataAlign = SlotInfo.DataAlign;
716 MaxFieldAlign = std::max(MaxFieldAlign, DataAlign);
719 if (
uint64_t Rem = CurrentOffset % DataAlignV) {
721 uint64_t Padding = DataAlignV - Rem;
722 Frame.padding(Ctx, Padding);
723 CurrentOffset += Padding;
726 if (SlotInfo.Indirect) {
727 Frame.store(Ctx, FrameFieldType, SourceValue);
730 Frame.memcpy(Ctx, FrameFieldType, SourceValue, UnderlyingSize);
732 Frame.store(Ctx, FrameFieldType, SourceValue);
735 CurrentOffset +=
DL.getTypeAllocSize(FrameFieldType).getFixedValue();
743 Frame.padding(Ctx, 1);
754 Align AllocaAlign = MaxFieldAlign;
756 StackAlign && *StackAlign > AllocaAlign)
757 AllocaAlign = *StackAlign;
760 Builder.SetInsertPointPastAllocas(CBF);
763 Builder.SetCurrentDebugLocation(CB->
getDebugLoc());
767 new AllocaInst(VarargsTy,
DL.getAllocaAddrSpace(),
nullptr, AllocaAlign),
773 Builder.SetInsertPoint(CB);
774 Builder.CreateLifetimeStart(Alloced);
775 Frame.initializeStructAlloca(
DL, Builder, Alloced, VarargsTy);
777 const unsigned NumArgs = VarargFunctionType->getNumParams();
784 if (!ABI->vaListPassedInSSARegister()) {
785 Type *VaListTy = ABI->vaListType(Ctx);
786 Builder.SetInsertPointPastAllocas(CBF);
787 Builder.SetCurrentDebugLocation(CB->
getDebugLoc());
788 VaList = Builder.CreateAlloca(VaListTy,
nullptr,
"va_argument");
789 Builder.SetInsertPoint(CB);
790 Builder.CreateLifetimeStart(VaList);
792 Builder.SetInsertPoint(CB);
793 Args.push_back(ABI->initializeVaList(M, Ctx, Builder, VaList, Alloced));
798 if (!PAL.isEmpty()) {
800 for (
unsigned ArgNo = 0; ArgNo < NumArgs; ArgNo++)
801 ArgAttrs.
push_back(PAL.getParamAttrs(ArgNo));
803 AttributeList::get(Ctx, PAL.getFnAttrs(), PAL.getRetAttrs(), ArgAttrs);
812 Value *Dst = NF ? NF : CI->getCalledOperand();
816 inlinableVariadicFunctionType(M, VarargFunctionType, CB->
getType());
818 NewCB =
CallInst::Create(NFTy, Dst, Args, OpBundles,
"", CI->getIterator());
826 CI->setTailCallKind(TCK);
833 Builder.CreateLifetimeEnd(VaList);
835 Builder.CreateLifetimeEnd(Alloced);
850bool ExpandVariadics::expandVAIntrinsicCall(
IRBuilder<> &Builder,
863 if (ContainingFunction->
isVarArg()) {
869 bool PassedByValue = ABI->vaListPassedInSSARegister();
876 Builder.SetInsertPoint(Inst);
882 assert(ABI->vaCopyIsMemcpy());
886 Value *Cursor = PassedVaList;
887 if (Cursor->getType() != VaStartArg->
getType())
888 Cursor = Builder.CreateAddrSpaceCast(Cursor, VaStartArg->
getType());
889 Builder.CreateStore(Cursor, VaStartArg);
893 auto &Ctx = Builder.getContext();
895 Builder.CreateIntrinsic(Intrinsic::vacopy, {
DL.getAllocaPtrType(Ctx)},
896 {VaStartArg, PassedVaList});
905 assert(ABI->vaEndIsNop());
910bool ExpandVariadics::expandVAIntrinsicCall(
IRBuilder<> &Builder,
913 assert(ABI->vaCopyIsMemcpy());
914 Builder.SetInsertPoint(Inst);
916 auto &Ctx = Builder.getContext();
917 Type *VaListTy = ABI->vaListType(Ctx);
920 Builder.CreateMemCpy(Inst->
getDest(), {}, Inst->
getSrc(), {},
921 Builder.getInt32(
Size));
927bool ExpandVariadics::expandVAArgInst(
IRBuilder<> &Builder,
929 Builder.SetInsertPoint(Inst);
931 auto &Ctx = Builder.getContext();
935 const VariadicABIInfo::VAArgSlotInfo SlotInfo = ABI->slotInfo(
DL, ValTy);
936 Type *FrameFieldType = SlotInfo.Indirect ?
DL.getAllocaPtrType(Ctx) : ValTy;
937 const uint64_t SlotSize =
DL.getTypeAllocSize(FrameFieldType).getFixedValue();
938 const Align SlotAlign = SlotInfo.DataAlign;
941 Type *IdxTy =
DL.getIndexType(PtrTy);
943 Value *Cur = Builder.CreateLoad(PtrTy, VaListPtr);
947 if (SlotAlign >
Align(1)) {
948 Value *RoundUp = Builder.CreateInBoundsPtrAdd(
949 Cur, ConstantInt::get(IdxTy, SlotAlign.
value() - 1));
950 Aligned = Builder.CreateIntrinsic(
951 Intrinsic::ptrmask, {PtrTy, IdxTy},
957 Builder.CreateInBoundsPtrAdd(
Aligned, ConstantInt::get(IdxTy, SlotSize));
958 Builder.CreateStore(
Next, VaListPtr);
962 Value *Result = Builder.CreateAlignedLoad(FrameFieldType,
Aligned, SlotAlign);
964 if (SlotInfo.Indirect)
965 Result = Builder.CreateLoad(ValTy, Result);
967 Result->takeName(Inst);
973struct Amdgpu final :
public VariadicABIInfo {
975 bool enableForTarget()
override {
return true; }
977 bool vaListPassedInSSARegister()
override {
return true; }
983 Type *vaListParameterType(
Module &M)
override {
991 return Builder.CreateAddrSpaceCast(Buffer, vaListParameterType(M));
995 return {
Align(4),
false};
999struct NVPTX final :
public VariadicABIInfo {
1001 bool enableForTarget()
override {
return true; }
1003 bool vaListPassedInSSARegister()
override {
return true; }
1009 Type *vaListParameterType(
Module &M)
override {
1015 return Builder.CreateAddrSpaceCast(Buffer, vaListParameterType(M));
1021 Align A =
DL.getABITypeAlign(Parameter);
1026struct SPIRV final :
public VariadicABIInfo {
1028 bool enableForTarget()
override {
return true; }
1030 bool vaListPassedInSSARegister()
override {
return true; }
1036 Type *vaListParameterType(
Module &M)
override {
1042 return Builder.CreateAddrSpaceCast(Buffer, vaListParameterType(M));
1048 Align A =
DL.getABITypeAlign(Parameter);
1053 bool ignoreFunction(
const Function *
F)
override {
1054 if (!
F->isDeclaration())
1067 DemangledName.
starts_with(
"printf(") ||
F->getName() ==
"printf")
1079struct Wasm final :
public VariadicABIInfo {
1083 bool enableForTarget()
override {
return false; }
1085 bool vaListPassedInSSARegister()
override {
return true; }
1091 Type *vaListParameterType(
Module &M)
override {
1103 Align A =
DL.getABITypeAlign(Parameter);
1108 if (S->getNumElements() > 1) {
1117std::unique_ptr<VariadicABIInfo> VariadicABIInfo::create(
const Triple &
T) {
1118 switch (
T.getArch()) {
1121 return std::make_unique<Amdgpu>();
1125 return std::make_unique<Wasm>();
1130 return std::make_unique<NVPTX>();
1136 return std::make_unique<SPIRV>();
1146char ExpandVariadics::ID = 0;
1152 return new ExpandVariadics(M);
1159 ExpandVariadics EV(Mode);
1161 if (!EV.runOnModule(M))
Ops append({Chain, DAG.getConstant(SVEStores[NumParts - 2], DL, MVT::i32)})
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static bool runOnFunction(Function &F, bool PostInlining)
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
NVPTX address space definition.
FunctionAnalysisManager FAM
ModuleAnalysisManager MAM
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
Provides some synthesis utilities to produce sequences of values.
This file defines the SmallVector class.
an instruction to allocate memory on the stack
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
This class represents an incoming formal argument to a Function.
static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
LLVM Basic Block Representation.
static BasicBlock * Create(LLVMContext &Context, const Twine &Name="", Function *Parent=nullptr, BasicBlock *InsertBefore=nullptr)
Creates a new BasicBlock.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
void setCallingConv(CallingConv::ID CC)
LLVM_ABI void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Return the list of operand bundles attached to this instruction as a vector of OperandBundleDefs.
Type * getParamByRefType(unsigned ArgNo) const
Extract the byref type for a call or parameter.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
CallingConv::ID getCallingConv() const
LLVM_ABI bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Determine whether the argument or parameter has the given attribute.
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
Type * getParamByValType(unsigned ArgNo) const
Extract the byval type for a call or parameter.
void setAttributes(AttributeList A)
Set the attributes for this call.
Value * getArgOperand(unsigned i) const
FunctionType * getFunctionType() const
unsigned arg_size() const
AttributeList getAttributes() const
Return the attributes for this call.
This class represents a function call, abstracting a target machine's calling convention.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
static ConstantInt * getSigned(IntegerType *Ty, int64_t V, bool ImplicitTrunc=false)
Return a ConstantInt with the specified value for the specified type.
LLVM_ABI void removeDeadConstantUsers() const
If there are any dead constant users dangling off of this constant, remove them.
A parsed version of the target data layout string in and methods for querying it.
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
LLVM_ABI ExpandVariadicsPass(ExpandVariadicsMode Mode)
static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
void splice(Function::iterator ToIt, Function *FromF)
Transfer all blocks from FromF to this function at ToIt.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
AttributeList getAttributes() const
Return the attribute list for this Function.
void setAttributes(AttributeList Attrs)
Set the attribute list for this Function.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Argument * getArg(unsigned i) const
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
void copyAttributesFrom(const Function *Src)
copyAttributesFrom - copy all additional attributes (those not needed to create a Function) from the ...
LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)
Set a particular kind of metadata attachment.
LLVM_ABI void setComdat(Comdat *C)
const Comdat * getComdat() const
LLVM_ABI void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this GlobalObject.
VisibilityTypes getVisibility() const
LLVM_ABI bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
LinkageTypes getLinkage() const
void setLinkage(LinkageTypes LT)
@ DefaultVisibility
The GV is visible.
void setVisibility(VisibilityTypes V)
@ InternalLinkage
Rename collisions when linking (static functions).
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
LLVM_ABI void copyProfileAndDebugMetadata(const Instruction &SrcInst)
Copy debug, profile, and memprof metadata from SrcInst to this instruction without copying alias-anal...
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
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.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
This is an important class for using LLVM in a threaded context.
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
A Module instance is used to store all the information related to an LLVM module.
static PointerType * getUnqual(LLVMContext &C)
This constructs an opaque pointer to an object in the default address space (address space zero).
static LLVM_ABI PointerType * get(LLVMContext &C, unsigned AddressSpace)
This constructs an opaque pointer to an object in a numbered address space.
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.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
Class to represent struct types.
static LLVM_ABI StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Triple - Helper class for working with autoconf configuration names.
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 * getInt8Ty(LLVMContext &C)
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
Value * getPointerOperand()
This represents the llvm.va_copy intrinsic.
This represents the llvm.va_end intrinsic.
This represents the llvm.va_start intrinsic.
Value * getArgList() const
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.
iterator_range< user_iterator > users()
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.
@ SPIR_FUNC
Used for SPIR non-kernel device functions.
@ C
The default llvm calling convention, compatible with C.
This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.
LLVM_ABI Function * getDeclarationIfExists(const Module *M, ID id)
Look up the Function declaration of the intrinsic id in the Module M and return it if it exists.
This is an optimization pass for GlobalISel generic memory operations.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
@ 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...
InnerAnalysisManagerProxy< FunctionAnalysisManager, Module > FunctionAnalysisManagerModuleProxy
Provide the FunctionAnalysisManager to Module proxy.
constexpr T MinAlign(U A, V B)
A and B are either alignments or offsets.
const IPOOptions & getIPOOptions(const LLVMContext &C)
LLVM_ABI ModulePass * createExpandVariadicsPass(ExpandVariadicsMode)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
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...
constexpr auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
DEMANGLE_ABI std::string demangle(std::string_view MangledName)
Attempt to demangle a string using different demangling schemes.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
This struct is a compact representation of a valid (non-zero power of two) alignment.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.