68#define DEBUG_TYPE "expand-variadics"
78 "Use the implementation defaults"),
80 "Disable the pass entirely"),
82 "Optimise without changing ABI"),
84 "Change variadic calling convention")));
86bool commandLineOverride() {
95class VariadicABIInfo {
97 VariadicABIInfo() =
default;
100 static std::unique_ptr<VariadicABIInfo> create(
const Triple &
T);
103 virtual bool enableForTarget() = 0;
108 virtual bool vaListPassedInSSARegister() = 0;
114 virtual Type *vaListParameterType(
Module &M) = 0;
123 struct VAArgSlotInfo {
130 bool vaEndIsNop() {
return true; }
131 bool vaCopyIsMemcpy() {
return true; }
134 virtual bool ignoreFunction(
const Function *
F) {
return false; }
142 virtual ~VariadicABIInfo() =
default;
157 std::unique_ptr<VariadicABIInfo> ABI;
161 Mode(commandLineOverride() ? ExpandVariadicsModeOption :
Mode) {}
163 StringRef getPassName()
const override {
return "Expand variadic functions"; }
167 template <
typename T>
bool isValidCallingConv(
T *
F) {
172 bool runOnModule(
Module &M)
override;
194 template <Intrinsic::ID ID,
typename InstructionType>
203 Changed |= expandVAIntrinsicCall(Builder,
DL,
I);
212 unsigned Addrspace) {
213 auto &Ctx = M.getContext();
218 Changed |= expandIntrinsicUsers<Intrinsic::vastart, VAStartInst>(
219 M, Builder, IntrinsicArgType);
220 Changed |= expandIntrinsicUsers<Intrinsic::vaend, VAEndInst>(
221 M, Builder, IntrinsicArgType);
222 Changed |= expandIntrinsicUsers<Intrinsic::vacopy, VACopyInst>(
223 M, Builder, IntrinsicArgType);
243 ArgTypes.
push_back(ABI->vaListParameterType(M));
248 return inlinableVariadicFunctionType(M, FTy, FTy->getReturnType());
252 if (
F->isIntrinsic() || !
F->isVarArg() ||
253 F->hasFnAttribute(Attribute::Naked))
256 if (ABI->ignoreFunction(
F))
259 if (!isValidCallingConv(
F))
265 if (!
F->hasExactDefinition())
271 bool expansionApplicableToFunctionCall(
CallBase *CB) {
273 if (CI->isMustTailCall()) {
278 if (!isValidCallingConv(CI))
293 class ExpandedCallFrame {
299 enum Tag { Store, Memcpy, Padding };
304 Source.push_back({V, Bytes, tag});
311 append<Memcpy>(
T, V, Bytes);
318 size_t size()
const {
return FieldTypes.
size(); }
319 bool empty()
const {
return FieldTypes.
empty(); }
322 const bool IsPacked =
true;
324 (
Twine(Name) +
".vararg").str(), IsPacked);
330 for (
size_t I = 0;
I <
size();
I++) {
332 auto [V, bytes, tag] = Source[
I];
334 if (tag == Padding) {
339 auto Dst = Builder.CreateStructGEP(VarargsTy, Alloced,
I);
344 Builder.CreateStore(V, Dst);
347 Builder.CreateMemCpy(Dst, {}, V, {}, bytes);
353bool ExpandVariadics::runOnModule(
Module &M) {
358 Triple TT(M.getTargetTriple());
359 ABI = VariadicABIInfo::create(TT);
363 if (!ABI->enableForTarget())
366 auto &Ctx = M.getContext();
382 unsigned Addrspace = 0;
383 Changed |= expandVAIntrinsicUsersWithAddrspace(M, Builder, Addrspace);
385 Addrspace =
DL.getAllocaAddrSpace();
387 Changed |= expandVAIntrinsicUsersWithAddrspace(M, Builder, Addrspace);
391 ABI->getTargetSpecificVaIntrinAddrSpaces();
392 for (
unsigned TargetAS : TargetASVec) {
393 if (TargetAS == 0 || TargetAS ==
DL.getAllocaAddrSpace())
395 Changed |= expandVAIntrinsicUsersWithAddrspace(M, Builder, TargetAS);
403 if (
F.isDeclaration())
413 Changed |= expandVAArgInst(Builder,
DL, VA);
415 if (CB->isIndirectCall()) {
418 Changed |= expandCall(M, Builder, CB, FTy,
nullptr);
432 if (!expansionApplicableToFunction(M, OriginalFunction))
435 [[maybe_unused]]
const bool OriginalFunctionIsDeclaration =
437 assert(rewriteABI() || !OriginalFunctionIsDeclaration);
441 replaceAllUsesWithNewDeclaration(M, OriginalFunction);
448 deriveFixedArityReplacement(M, Builder, OriginalFunction);
451 OriginalFunctionIsDeclaration);
455 [[maybe_unused]]
Function *VariadicWrapperDefine =
456 defineVariadicWrapper(M, Builder, VariadicWrapper, FixedArityReplacement);
457 assert(VariadicWrapperDefine == VariadicWrapper);
464 LLVMContext::MD_prof,
465 FixedArityReplacement->
getMetadata(LLVMContext::MD_prof));
475 Value *CalledOperand = CB->getCalledOperand();
476 if (VariadicWrapper == CalledOperand)
479 FixedArityReplacement);
487 Function *
const ExternallyAccessible =
488 rewriteABI() ? FixedArityReplacement : VariadicWrapper;
490 rewriteABI() ? VariadicWrapper : FixedArityReplacement;
496 ExternallyAccessible->
takeName(OriginalFunction);
518ExpandVariadics::replaceAllUsesWithNewDeclaration(
Module &M,
525 NF->
setName(
F.getName() +
".varargs");
527 F.getParent()->getFunctionList().insert(
F.getIterator(), NF);
529 AttrBuilder ParamAttrs(Ctx);
531 Attrs = Attrs.addParamAttributes(Ctx, FTy->getNumParams(), ParamAttrs);
547 assert(expansionApplicableToFunction(M, &
F));
549 auto &Ctx = M.getContext();
553 const bool FunctionIsDefinition = !
F.isDeclaration();
557 ArgTypes.
push_back(ABI->vaListParameterType(M));
559 FunctionType *NFTy = inlinableVariadicFunctionType(M, FTy);
565 F.getParent()->getFunctionList().insert(
F.getIterator(), NF);
566 NF->
setName(
F.getName() +
".valist");
568 AttrBuilder ParamAttrs(Ctx);
571 Attrs = Attrs.addParamAttributes(Ctx, NFTy->getNumParams() - 1, ParamAttrs);
575 if (FunctionIsDefinition) {
580 Arg.replaceAllUsesWith(NewArg);
581 NewArg->setName(Arg.getName());
588 F.getAllMetadata(MDs);
589 for (
auto [KindID,
Node] : MDs)
606 Type *VaListTy = ABI->vaListType(Ctx);
609 Builder.SetInsertPoint(BB);
612 Builder.CreateAlloca(VaListTy,
nullptr,
"va_start");
614 Builder.CreateLifetimeStart(VaListInstance);
616 Builder.CreateIntrinsic(Intrinsic::vastart, {
DL.getAllocaPtrType(Ctx)},
621 Type *ParameterType = ABI->vaListParameterType(M);
622 if (ABI->vaListPassedInSSARegister())
623 Args.push_back(Builder.CreateLoad(ParameterType, VaListInstance));
625 Args.push_back(Builder.CreateAddrSpaceCast(VaListInstance, ParameterType));
627 CallInst *Result = Builder.CreateCall(FixedArityReplacement, Args);
629 Builder.CreateIntrinsic(Intrinsic::vaend, {
DL.getAllocaPtrType(Ctx)},
631 Builder.CreateLifetimeEnd(VaListInstance);
633 if (Result->getType()->isVoidTy())
634 Builder.CreateRetVoid();
636 Builder.CreateRet(Result);
638 return VariadicWrapper;
650 if (!expansionApplicableToFunctionCall(CB)) {
665 Align MaxFieldAlign(1);
675 ExpandedCallFrame Frame;
679 for (
unsigned I :
seq(VarargFunctionType->getNumParams(), CB->
arg_size())) {
690 DL.getTypeAllocSize(UnderlyingType).getFixedValue();
693 Type *FrameFieldType = UnderlyingType;
696 Value *SourceValue = ArgVal;
698 VariadicABIInfo::VAArgSlotInfo SlotInfo = ABI->slotInfo(
DL, UnderlyingType);
700 if (SlotInfo.Indirect) {
703 Builder.SetInsertPointPastAllocas(CBF);
706 Builder.CreateAlloca(UnderlyingType,
nullptr,
"IndirectAlloca");
708 Builder.SetInsertPoint(CB);
710 Builder.CreateMemCpy(CallerCopy, {}, ArgVal, {}, UnderlyingSize);
712 Builder.CreateStore(ArgVal, CallerCopy);
715 FrameFieldType =
DL.getAllocaPtrType(Ctx);
716 SourceValue = CallerCopy;
721 Align DataAlign = SlotInfo.DataAlign;
723 MaxFieldAlign = std::max(MaxFieldAlign, DataAlign);
726 if (
uint64_t Rem = CurrentOffset % DataAlignV) {
728 uint64_t Padding = DataAlignV - Rem;
729 Frame.padding(Ctx, Padding);
730 CurrentOffset += Padding;
733 if (SlotInfo.Indirect) {
734 Frame.store(Ctx, FrameFieldType, SourceValue);
737 Frame.memcpy(Ctx, FrameFieldType, SourceValue, UnderlyingSize);
739 Frame.store(Ctx, FrameFieldType, SourceValue);
742 CurrentOffset +=
DL.getTypeAllocSize(FrameFieldType).getFixedValue();
750 Frame.padding(Ctx, 1);
761 Align AllocaAlign = MaxFieldAlign;
763 StackAlign && *StackAlign > AllocaAlign)
764 AllocaAlign = *StackAlign;
767 Builder.SetInsertPointPastAllocas(CBF);
774 new AllocaInst(VarargsTy,
DL.getAllocaAddrSpace(),
nullptr, AllocaAlign),
780 Builder.SetInsertPoint(CB);
781 Builder.CreateLifetimeStart(Alloced);
782 Frame.initializeStructAlloca(
DL, Builder, Alloced, VarargsTy);
784 const unsigned NumArgs = VarargFunctionType->getNumParams();
791 if (!ABI->vaListPassedInSSARegister()) {
792 Type *VaListTy = ABI->vaListType(Ctx);
793 Builder.SetInsertPointPastAllocas(CBF);
795 VaList = Builder.CreateAlloca(VaListTy,
nullptr,
"va_argument");
796 Builder.SetInsertPoint(CB);
797 Builder.CreateLifetimeStart(VaList);
799 Builder.SetInsertPoint(CB);
800 Args.push_back(ABI->initializeVaList(M, Ctx, Builder, VaList, Alloced));
805 if (!PAL.isEmpty()) {
807 for (
unsigned ArgNo = 0; ArgNo < NumArgs; ArgNo++)
808 ArgAttrs.
push_back(PAL.getParamAttrs(ArgNo));
810 AttributeList::get(Ctx, PAL.getFnAttrs(), PAL.getRetAttrs(), ArgAttrs);
819 Value *Dst = NF ? NF : CI->getCalledOperand();
823 inlinableVariadicFunctionType(M, VarargFunctionType, CB->
getType());
825 NewCB =
CallInst::Create(NFTy, Dst, Args, OpBundles,
"", CI->getIterator());
833 CI->setTailCallKind(TCK);
840 Builder.CreateLifetimeEnd(VaList);
842 Builder.CreateLifetimeEnd(Alloced);
850 NewCB->
copyMetadata(*CB, {LLVMContext::MD_prof, LLVMContext::MD_dbg});
857bool ExpandVariadics::expandVAIntrinsicCall(
IRBuilder<> &Builder,
870 if (ContainingFunction->
isVarArg()) {
876 bool PassedByValue = ABI->vaListPassedInSSARegister();
883 Builder.SetInsertPoint(Inst);
889 assert(ABI->vaCopyIsMemcpy());
890 Builder.CreateStore(PassedVaList, VaStartArg);
894 auto &Ctx = Builder.getContext();
896 Builder.CreateIntrinsic(Intrinsic::vacopy, {
DL.getAllocaPtrType(Ctx)},
897 {VaStartArg, PassedVaList});
906 assert(ABI->vaEndIsNop());
911bool ExpandVariadics::expandVAIntrinsicCall(
IRBuilder<> &Builder,
914 assert(ABI->vaCopyIsMemcpy());
915 Builder.SetInsertPoint(Inst);
917 auto &Ctx = Builder.getContext();
918 Type *VaListTy = ABI->vaListType(Ctx);
921 Builder.CreateMemCpy(Inst->
getDest(), {}, Inst->
getSrc(), {},
922 Builder.getInt32(
Size));
928bool ExpandVariadics::expandVAArgInst(
IRBuilder<> &Builder,
930 Builder.SetInsertPoint(Inst);
932 auto &Ctx = Builder.getContext();
936 const VariadicABIInfo::VAArgSlotInfo SlotInfo = ABI->slotInfo(
DL, ValTy);
937 Type *FrameFieldType = SlotInfo.Indirect ?
DL.getAllocaPtrType(Ctx) : ValTy;
938 const uint64_t SlotSize =
DL.getTypeAllocSize(FrameFieldType).getFixedValue();
939 const Align SlotAlign = SlotInfo.DataAlign;
942 Type *IdxTy =
DL.getIndexType(PtrTy);
944 Value *Cur = Builder.CreateLoad(PtrTy, VaListPtr);
948 if (SlotAlign >
Align(1)) {
949 Value *RoundUp = Builder.CreateInBoundsPtrAdd(
950 Cur, ConstantInt::get(IdxTy, SlotAlign.
value() - 1));
951 Aligned = Builder.CreateIntrinsic(
952 Intrinsic::ptrmask, {PtrTy, IdxTy},
958 Builder.CreateInBoundsPtrAdd(
Aligned, ConstantInt::get(IdxTy, SlotSize));
959 Builder.CreateStore(
Next, VaListPtr);
963 Value *Result = Builder.CreateAlignedLoad(FrameFieldType,
Aligned, SlotAlign);
965 if (SlotInfo.Indirect)
966 Result = Builder.CreateLoad(ValTy, Result);
968 Result->takeName(Inst);
974struct Amdgpu final :
public VariadicABIInfo {
976 bool enableForTarget()
override {
return true; }
978 bool vaListPassedInSSARegister()
override {
return true; }
984 Type *vaListParameterType(
Module &M)
override {
992 return Builder.CreateAddrSpaceCast(Buffer, vaListParameterType(M));
996 return {
Align(4),
false};
1000struct NVPTX final :
public VariadicABIInfo {
1002 bool enableForTarget()
override {
return true; }
1004 bool vaListPassedInSSARegister()
override {
return true; }
1010 Type *vaListParameterType(
Module &M)
override {
1016 return Builder.CreateAddrSpaceCast(Buffer, vaListParameterType(M));
1022 Align A =
DL.getABITypeAlign(Parameter);
1027struct SPIRV final :
public VariadicABIInfo {
1029 bool enableForTarget()
override {
return true; }
1031 bool vaListPassedInSSARegister()
override {
return true; }
1037 Type *vaListParameterType(
Module &M)
override {
1043 return Builder.CreateAddrSpaceCast(Buffer, vaListParameterType(M));
1049 Align A =
DL.getABITypeAlign(Parameter);
1054 bool ignoreFunction(
const Function *
F)
override {
1055 if (!
F->isDeclaration())
1075struct Wasm final :
public VariadicABIInfo {
1077 bool enableForTarget()
override {
1079 return commandLineOverride();
1082 bool vaListPassedInSSARegister()
override {
return true; }
1088 Type *vaListParameterType(
Module &M)
override {
1100 Align A =
DL.getABITypeAlign(Parameter);
1105 if (S->getNumElements() > 1) {
1114std::unique_ptr<VariadicABIInfo> VariadicABIInfo::create(
const Triple &
T) {
1115 switch (
T.getArch()) {
1118 return std::make_unique<Amdgpu>();
1122 return std::make_unique<Wasm>();
1127 return std::make_unique<NVPTX>();
1133 return std::make_unique<SPIRV>();
1143char ExpandVariadics::ID = 0;
1149 return new ExpandVariadics(M);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
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.
#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 eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing module and deletes it.
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 const DebugLoc & getStableDebugLoc() const
Fetch the debug location for this node, unless this is a debug intrinsic, in which case fetch the deb...
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.
LLVM_ABI void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to 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(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
static LLVM_ABI PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ 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.
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
initializer< Ty > init(const Ty &Val)
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.
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...
constexpr T MinAlign(U A, V B)
A and B are either alignments or offsets.
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...
FunctionAddr VTableAddr Next
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
auto seq(T Begin, T End)
Iterate over an integral type from Begin up to - but not including - End.
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.