1//===- llvm/Function.h - Class to represent a single function ---*- C++ -*-===// 
  3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 
  4// See https://llvm.org/LICENSE.txt for license information. 
  5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 
  7//===----------------------------------------------------------------------===// 
  9// This file contains the declaration of the Function class, which represents a 
  10// single function/procedure in LLVM. 
  12// A function basically consists of a list of basic blocks, a list of arguments, 
  15//===----------------------------------------------------------------------===// 
  17#ifndef LLVM_IR_FUNCTION_H 
  18#define LLVM_IR_FUNCTION_H 
  68 // BasicBlock iterators... 
  78 // Important things that make up a function! 
  81 // Basic blocks need to get their number when added to a function. 
  82  friend void BasicBlock::setParent(Function *);
 
  83 unsigned NextBlockNum = 0;
 
  84 /// Epoch of block numbers. (Could be shrinked to uint8_t if required.) 
  85 unsigned BlockNumEpoch = 0;
 
  87 mutable Argument *Arguments = 
nullptr; 
///< The formal arguments 
  89 std::unique_ptr<ValueSymbolTable>
 
  90 SymTab; 
///< Symbol table of args/instructions 
  91  AttributeList AttributeSets; 
///< Parameter attributes 
  96 * bit 0 : HasLazyArguments 
  97 * bit 1 : HasPrefixData 
  98 * bit 2 : HasPrologueData 
  99 * bit 3 : HasPersonalityFn 
  100 * bits 4-13 : CallingConvention 
  102 * bits 15 : [reserved] 
  105 /// Bits from GlobalObject::GlobalObjectSubclassData. 
  107 /// Whether this function is materializable. 
  108 IsMaterializableBit = 0,
 
  114 /// hasLazyArguments/CheckLazyArguments - The argument list of a function is 
  115 /// built on demand, so that the list isn't allocated until the first client 
  116 /// needs it. The hasLazyArguments predicate returns true if the arg list 
  117 /// hasn't been set up yet. 
  122 /// \see BasicBlock::convertToNewDbgValues. 
  123 void convertToNewDbgValues();
 
  125 /// \see BasicBlock::convertFromNewDbgValues. 
  126 void convertFromNewDbgValues();
 
  133 /// Cache for TLI::getLibFunc() result without prototype validation. 
  134 /// UnknownLibFunc if uninitialized. NotLibFunc if definitely not lib func. 
  135 /// Otherwise may be libfunc if prototype validation passes. 
  136 mutable LibFunc LibFuncCache = UnknownLibFunc;
 
  138 void CheckLazyArguments()
 const {
 
  140 BuildLazyArguments();
 
  143 void BuildLazyArguments() 
const;
 
  145 void clearArguments();
 
  147 void deleteBodyImpl(
bool ShouldDrop);
 
  149 /// Function ctor - If the (optional) Module argument is specified, the 
  150 /// function is automatically inserted into the end of the function list for 
  161 // This is here to help easily convert from FunctionT * (Function * or 
  162 // MachineFunction *) in BlockFrequencyInfoImpl to Function * by calling 
  163 // FunctionT->getFunction(). 
  167 unsigned AddrSpace, 
const Twine &
N = 
"",
 
  169 return new (AllocMarker) Function(Ty, 
Linkage, AddrSpace, 
N, M);
 
 
  172 // TODO: remove this once all users have been updated to pass an AddrSpace 
  175 return new (AllocMarker)
 
  176 Function(Ty, 
Linkage, 
static_cast<unsigned>(-1), 
N, M);
 
 
  179 /// Creates a new function and attaches it to a module. 
  181 /// Places the function in the program address space as specified 
  182 /// by the module's data layout. 
  186 /// Creates a function with some attributes recorded in llvm.module.flags 
  187 /// and the LLVMContext applied. 
  189 /// Use this when synthesizing new functions that need attributes that would 
  190 /// have been set by command line options. 
  192 /// This function should not be called from backends or the LTO pipeline. If 
  193 /// it is called from one of those places, some default attributes will not be 
  194 /// applied to the function. 
  200 // Provide fast operand accessors. 
  203 /// Returns the number of non-debug IR instructions in this function. 
  204 /// This is equivalent to the sum of the sizes of each basic block contained 
  205 /// within this function. 
  208 /// Returns the FunctionType for me. 
  213 /// Returns the type of the ret val. 
  216 /// getContext - Return a reference to the LLVMContext associated with this 
  220 /// Get the data layout of the module this function belongs to. 
  222 /// Requires the function to have a parent module. 
  225 /// isVarArg - Return true if this function takes a variable number of 
  233 unsigned Mask = 1 << IsMaterializableBit;
 
 
  238 /// getIntrinsicID - This method returns the ID number of the specified 
  239 /// function, or Intrinsic::not_intrinsic if the function is not an 
  240 /// intrinsic, or if the pointer is null. This value is always defined to be 
  241 /// zero to allow easy checking for whether a function is intrinsic or not. 
  242 /// The particular intrinsic functions which correspond to this value are 
  243 /// defined in llvm/Intrinsics.h. 
  246 /// isIntrinsic - Returns true if the function's name starts with "llvm.". 
  247 /// It's possible for this function to return true while getIntrinsicID() 
  248 /// returns Intrinsic::not_intrinsic! 
  251 /// isTargetIntrinsic - Returns true if this function is an intrinsic and the 
  252 /// intrinsic is specific to a certain target. If this is not an intrinsic 
  253 /// or a generic intrinsic, false is returned. 
  254 bool isTargetIntrinsic() 
const;
 
  256 /// Returns true if the function is one of the "Constrained Floating-Point 
  257 /// Intrinsics". Returns false if not, and returns false when 
  258 /// getIntrinsicID() returns Intrinsic::not_intrinsic. 
  259 bool isConstrainedFPIntrinsic() 
const;
 
  261 /// Update internal caches that depend on the function name (such as the 
  262 /// intrinsic ID and libcall cache). 
  263 /// Note, this method does not need to be called directly, as it is called 
  264 /// from Value::setName() whenever the name of this function changes. 
  265 void updateAfterNameChange();
 
  267 /// getCallingConv()/setCallingConv(CC) - These method get and set the 
  268 /// calling convention of this function. The enum values for the known 
  269 /// calling conventions are defined in CallingConv.h. 
  275 auto ID = 
static_cast<unsigned>(CC);
 
 
  280 /// Does it have a kernel calling convention? 
  294 /// Class to represent profile counts. 
  296 /// This class represents both real and synthetic profile counts. 
  304 : Count(Count), PCT(PCT) {}
 
 
 
  310 /// Set the entry count for this function. 
  312 /// Entry count is the number of times this function was executed based on 
  313 /// pgo data. \p Imports points to a set of GUIDs that needs to 
  314 /// be imported by the function for sample PGO, to enable the same inlines as 
  315 /// the profiled optimized binary. 
  319 /// A convenience wrapper for setting entry count 
  323 /// Get the entry count for this function. 
  325 /// Entry count is the number of times the function was executed. 
  326 /// When AllowSynthetic is false, only pgo_data will be returned. 
  327 std::optional<ProfileCount> getEntryCount(
bool AllowSynthetic = 
false) 
const;
 
  329 /// Return true if the function is annotated with profile data. 
  331 /// Presence of entry counts from a profile run implies the function has 
  332 /// profile annotations. If IncludeSynthetic is false, only return true 
  333 /// when the profile data is real. 
  338 /// Returns the set of GUIDs that needs to be imported to the function for 
  339 /// sample PGO, to enable the same inlines as the profiled optimized binary. 
  342 /// hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm 
  343 /// to use during code generation. 
  347 const std::string &getGC() 
const;
 
  348 void setGC(std::string Str);
 
  351 /// Return the attribute list for this Function. 
  354 /// Set the attribute list for this Function. 
  357 // TODO: remove non-AtIndex versions of these methods. 
  358 /// adds the attribute to the list of attributes. 
  359 void addAttributeAtIndex(
unsigned i, 
Attribute Attr);
 
  361 /// Add function attributes to this function. 
  364 /// Add function attributes to this function. 
  367 /// Add function attributes to this function. 
  370 /// Add function attributes to this function. 
  371 void addFnAttrs(
const AttrBuilder &Attrs);
 
  373 /// Add return value attributes to this function. 
  376 /// Add return value attributes to this function. 
  379 /// Add return value attributes to this function. 
  380 void addRetAttrs(
const AttrBuilder &Attrs);
 
  382 /// adds the attribute to the list of attributes for the given arg. 
  385 /// adds the attribute to the list of attributes for the given arg. 
  386 void addParamAttr(
unsigned ArgNo, 
Attribute Attr);
 
  388 /// adds the attributes to the list of attributes for the given arg. 
  389 void addParamAttrs(
unsigned ArgNo, 
const AttrBuilder &Attrs);
 
  391 /// removes the attribute from the list of attributes. 
  394 /// removes the attribute from the list of attributes. 
  395 void removeAttributeAtIndex(
unsigned i, 
StringRef Kind);
 
  397 /// Remove function attributes from this function. 
  400 /// Remove function attribute from this function. 
  405 /// removes the attribute from the return value list of attributes. 
  408 /// removes the attribute from the return value list of attributes. 
  411 /// removes the attributes from the return value list of attributes. 
  414 /// removes the attribute from the list of attributes. 
  417 /// removes the attribute from the list of attributes. 
  418 void removeParamAttr(
unsigned ArgNo, 
StringRef Kind);
 
  420 /// removes the attribute from the list of attributes. 
  421 void removeParamAttrs(
unsigned ArgNo, 
const AttributeMask &Attrs);
 
  423 /// Return true if the function has the attribute. 
  426 /// Return true if the function has the attribute. 
  427 bool hasFnAttribute(
StringRef Kind) 
const;
 
  429 /// check if an attribute is in the list of attributes for the return value. 
  432 /// check if an attributes is in the list of attributes. 
  435 /// Check if an attribute is in the list of attributes. 
  436 bool hasParamAttribute(
unsigned ArgNo, 
StringRef Kind) 
const;
 
  438 /// gets the attribute from the list of attributes. 
  441 /// gets the attribute from the list of attributes. 
  444 /// Check if attribute of the given kind is set at the given index. 
  447 /// Return the attribute for the given attribute kind. 
  450 /// Return the attribute for the given attribute kind. 
  453 /// Return the attribute for the given attribute kind for the return value. 
  456 /// For a string attribute \p Kind, parse attribute as an integer. 
  458 /// \returns \p Default if attribute is not present. 
  460 /// \returns \p Default if there is an error parsing the attribute integer, 
  461 /// and error is emitted to the LLVMContext 
  465 /// gets the specified attribute from the list of attributes. 
  468 /// Return the stack alignment for the function. 
  470 return AttributeSets.getFnStackAlignment();
 
 
  473 /// Returns true if the function has ssp, sspstrong, or sspreq fn attrs. 
  474 bool hasStackProtectorFnAttr() 
const;
 
  476 /// adds the dereferenceable attribute to the list of attributes for 
  478 void addDereferenceableParamAttr(
unsigned ArgNo, 
uint64_t Bytes);
 
  480 /// adds the dereferenceable_or_null attribute to the list of 
  481 /// attributes for the given arg. 
  482 void addDereferenceableOrNullParamAttr(
unsigned ArgNo, 
uint64_t Bytes);
 
  484 /// adds the range attribute to the list of attributes for the return value. 
  488 return AttributeSets.getParamAlignment(ArgNo);
 
 
  492 return AttributeSets.getParamStackAlignment(ArgNo);
 
 
  495 /// Extract the byval type for a parameter. 
  497 return AttributeSets.getParamByValType(ArgNo);
 
 
  500 /// Extract the sret type for a parameter. 
  502 return AttributeSets.getParamStructRetType(ArgNo);
 
 
  505 /// Extract the inalloca type for a parameter. 
  507 return AttributeSets.getParamInAllocaType(ArgNo);
 
 
  510 /// Extract the byref type for a parameter. 
  512 return AttributeSets.getParamByRefType(ArgNo);
 
 
  515 /// Extract the preallocated type for a parameter. 
  517 return AttributeSets.getParamPreallocatedType(ArgNo);
 
 
  520 /// Extract the number of dereferenceable bytes for a parameter. 
  521 /// @param ArgNo Index of an argument, with 0 being the first function arg. 
  523 return AttributeSets.getParamDereferenceableBytes(ArgNo);
 
 
  526 /// Extract the number of dereferenceable_or_null bytes for a 
  528 /// @param ArgNo AttributeList ArgNo, referring to an argument. 
  530 return AttributeSets.getParamDereferenceableOrNullBytes(ArgNo);
 
 
  533 /// Extract the nofpclass attribute for a parameter. 
  535 return AttributeSets.getParamNoFPClass(ArgNo);
 
 
  538 /// Determine if the function is presplit coroutine. 
  549 addFnAttr(Attribute::CoroDestroyOnlyWhenComplete);
 
 
  555 /// Determine if the function does not access memory. 
  556 bool doesNotAccessMemory() 
const;
 
  559 /// Determine if the function does not access or only reads memory. 
  560 bool onlyReadsMemory() 
const;
 
  563 /// Determine if the function does not access or only writes memory. 
  564 bool onlyWritesMemory() 
const;
 
  567 /// Determine if the call can access memory only using pointers based 
  568 /// on its arguments. 
  569 bool onlyAccessesArgMemory() 
const;
 
  572 /// Determine if the function may only access memory that is 
  573 /// inaccessible from the IR. 
  574 bool onlyAccessesInaccessibleMemory() 
const;
 
  577 /// Determine if the function may only access memory that is 
  578 /// either inaccessible from the IR or pointed to by its arguments. 
  579 bool onlyAccessesInaccessibleMemOrArgMem() 
const;
 
  582 /// Determine if the function cannot return. 
  590 /// Determine if the function should not perform indirect branch tracking. 
  593 /// Determine if the function cannot unwind. 
  601 /// Determine if the call cannot be duplicated. 
  609 /// Determine if the call is convergent. 
  620 /// Determine if the call has sideeffects. 
  628 /// Determine if the call might deallocate memory. 
  636 /// Determine if the call can synchroize with other threads 
  644 /// Determine if the function is known not to recurse, directly or 
  653 /// Determine if the function is required to make forward progress. 
  660 /// Determine if the function will return. 
  664 /// Get what kind of unwind table entry to generate for this function. 
  666 return AttributeSets.getUWTableKind();
 
 
  669 /// True if the ABI mandates (or the user requested) that this 
  670 /// function be in a unwind table. 
  680 /// True if this function needs an unwind table. 
  685 /// Determine if the function returns a structure through first 
  686 /// or second pointer argument. 
  688 return AttributeSets.hasParamAttr(0, Attribute::StructRet) ||
 
  689 AttributeSets.hasParamAttr(1, Attribute::StructRet);
 
 
  692 /// Determine if the parameter or return value is marked with NoAlias 
  695 return AttributeSets.hasRetAttr(Attribute::NoAlias);
 
 
  699 /// Do not optimize this function (-O0). 
  702 /// Optimize this function for minimum size (-Oz). 
  705 /// Optimize this function for size (-Os) or minimum size (-Oz). 
  710 /// Returns the denormal handling type for the default rounding mode of the 
  714 /// Return the representational value of "denormal-fp-math". Code interested 
  715 /// in the semantics of the function should use getDenormalMode instead. 
  718 /// Return the representational value of "denormal-fp-math-f32". Code 
  719 /// interested in the semantics of the function should use getDenormalMode 
  723 /// copyAttributesFrom - copy all additional attributes (those not needed to 
  724 /// create a Function) from the Function Src to this one. 
  725 void copyAttributesFrom(
const Function *Src);
 
  727 /// deleteBody - This method deletes the body of the function, and converts 
  728 /// the linkage to external. 
  731 deleteBodyImpl(
/*ShouldDrop=*/false);
 
 
  735 /// removeFromParent - This method unlinks 'this' from the containing module, 
  736 /// but does not delete it. 
  738 void removeFromParent();
 
  740 /// eraseFromParent - This method unlinks 'this' from the containing module 
  743 void eraseFromParent();
 
  745 /// Steal arguments from another function. 
  747 /// Drop this function's arguments and splice in the ones from \c Src. 
  748 /// Requires that this has no function body. 
  749 void stealArgumentListFrom(
Function &Src);
 
  751 /// Insert \p BB in the basic block list at \p Position. \Returns an iterator 
  752 /// to the newly inserted BB. 
  758 /// Transfer all blocks from \p FromF to this function at \p ToIt. 
  763 /// Transfer one BasicBlock from \p FromF at \p FromIt to this function 
  767 auto FromItNext = std::next(FromIt);
 
  768 // Single-element splice is a noop if destination == source. 
  769 if (ToIt == FromIt || ToIt == FromItNext)
 
  771 splice(ToIt, FromF, FromIt, FromItNext);
 
 
  774 /// Transfer a range of basic blocks that belong to \p FromF from \p 
  775 /// FromBeginIt to \p FromEndIt, to this function at \p ToIt. 
  780 /// Erases a range of BasicBlocks from \p FromIt to (not including) \p ToIt. 
  781 /// \Returns \p ToIt. 
  785 // These need access to the underlying BB list. 
  788 template <
class BB_t, 
class BB_i_t, 
class BI_t, 
class II_t>
 
  793 /// Get the underlying elements of the Function... the basic block list is 
  794 /// empty for external functions. 
  796 /// This is deliberately private because we have implemented an adequate set 
  797 /// of functions to modify the list, including Function::splice(), 
  798 /// Function::erase(), Function::insert() etc. 
  803 return &Function::BasicBlocks;
 
  810 //===--------------------------------------------------------------------===// 
  811 // Symbol Table Accessing functions... 
  813 /// getSymbolTable() - Return the symbol table if any, otherwise nullptr. 
  820 //===--------------------------------------------------------------------===// 
  821 // Block number functions 
  823 /// Return a value larger than the largest block number. Intended to allocate 
  824 /// a vector that is sufficiently large to hold all blocks indexed by their 
  828 /// Renumber basic blocks into a dense value range starting from 0. Be aware 
  829 /// that other data structures and analyses (e.g., DominatorTree) may depend 
  830 /// on the value numbers and need to be updated or invalidated. 
  831 void renumberBlocks();
 
  833 /// Return the "epoch" of current block numbers. This will return a different 
  834 /// value after every renumbering. The intention is: if something (e.g., an 
  835 /// analysis) uses block numbers, it also stores the number epoch and then 
  836 /// can assert later on that the epoch didn't change (indicating that the 
  837 /// numbering is still valid). If the epoch changed, blocks might have been 
  838 /// assigned new numbers and previous uses of the numbers needs to be 
  839 /// invalidated. This is solely intended as a debugging feature. 
  843 /// Assert that all blocks have unique numbers within 0..NextBlockNum. This 
  844 /// has O(n) runtime complexity. 
  845 void validateBlockNumbers() 
const;
 
  848 //===--------------------------------------------------------------------===// 
  849 // BasicBlock iterator forwarding functions 
  856  size_t size()
 const { 
return BasicBlocks.size(); }
 
  857  bool empty()
 const { 
return BasicBlocks.empty(); }
 
  863/// @name Function Argument Iteration 
  867 CheckLazyArguments();
 
 
  871 CheckLazyArguments();
 
 
  876 CheckLazyArguments();
 
  877 return Arguments + NumArgs;
 
 
  880 CheckLazyArguments();
 
  881 return Arguments + NumArgs;
 
 
  885 assert (i < NumArgs && 
"getArg() out of range!");
 
  886 CheckLazyArguments();
 
  887 return Arguments + i;
 
 
  902 /// Check whether this function has a personality function. 
  907 /// Get the personality function associated with this function. 
  909 void setPersonalityFn(
Constant *Fn);
 
  911 /// Check whether this function has prefix data. 
  916 /// Get the prefix data associated with this function. 
  918 void setPrefixData(
Constant *PrefixData);
 
  920 /// Check whether this function has prologue data. 
  925 /// Get the prologue data associated with this function. 
  927 void setPrologueData(
Constant *PrologueData);
 
  929 /// Print the function to an output stream with an optional 
  930 /// AssemblyAnnotationWriter. 
  932 bool ShouldPreserveUseListOrder = 
false,
 
  933 bool IsForDebug = 
false) 
const;
 
  935 /// viewCFG - This function is meant for use from the debugger. You can just 
  936 /// say 'call F->viewCFG()' and a ghostview window should pop up from the 
  937 /// program, displaying the CFG of the current function with the code for each 
  938 /// basic block inside. This depends on there being a 'dot' and 'gv' program 
  943 /// viewCFG - This function is meant for use from the debugger. It works just 
  944 /// like viewCFG(), but generates the dot file with the given file name. 
  945 void viewCFG(
const char *OutputFileName) 
const;
 
  947 /// Extended form to print edge weights. 
  950 const char *OutputFileName = 
nullptr) 
const;
 
  952 /// viewCFGOnly - This function is meant for use from the debugger. It works 
  953 /// just like viewCFG, but it does not include the contents of basic blocks 
  954 /// into the nodes, just the label. If you are only interested in the CFG 
  955 /// this can make the graph smaller. 
  957 void viewCFGOnly() 
const;
 
  959 /// viewCFG - This function is meant for use from the debugger. It works just 
  960 /// like viewCFGOnly(), but generates the dot file with the given file name. 
  961 void viewCFGOnly(
const char *OutputFileName) 
const;
 
  963 /// Extended form to print edge weights. 
  967 /// Methods for support type inquiry through isa, cast, and dyn_cast: 
  969 return V->getValueID() == Value::FunctionVal;
 
 
  972 /// dropAllReferences() - This method causes all the subinstructions to "let 
  973 /// go" of all references that they are maintaining. This allows one to 
  974 /// 'delete' a whole module at a time, even though there may be circular 
  975 /// references... first all references are dropped, and all use counts go to 
  976 /// zero. Then everything is deleted for real. Note that no operations are 
  977 /// valid on an object that has "dropped all references", except operator 
  980 /// Since no other object in the module can have references into the body of a 
  981 /// function, dropping all references deletes the entire body of the function, 
  982 /// including any contained basic blocks. 
  985 deleteBodyImpl(
/*ShouldDrop=*/true);
 
 
  988 /// hasAddressTaken - returns true if there are any uses of this function 
  989 /// other than direct calls or invokes to it, or blockaddress expressions. 
  990 /// Optionally passes back an offending user for diagnostic purposes, 
  991 /// ignores callback uses, assume like pointer annotation calls, references in 
  992 /// llvm.used and llvm.compiler.used variables, operand bundle 
  993 /// "clang.arc.attachedcall", and direct calls with a different call site 
  994 /// signature (the function is implicitly casted). 
  995 bool hasAddressTaken(
const User ** = 
nullptr, 
bool IgnoreCallbackUses = 
false,
 
  996 bool IgnoreAssumeLikeCalls = 
true,
 
  997 bool IngoreLLVMUsed = 
false,
 
  998 bool IgnoreARCAttachedCall = 
false,
 
  999 bool IgnoreCastedDirectCall = 
false) 
const;
 
  1001 /// isDefTriviallyDead - Return true if it is trivially safe to remove 
  1002 /// this function definition from the module (because it isn't externally 
  1003 /// visible, does not have its address taken, and has no callers). To make 
  1004 /// this more accurate, call removeDeadConstantUsers first. 
  1005 bool isDefTriviallyDead() 
const;
 
  1007 /// callsFunctionThatReturnsTwice - Return true if the function has a call to 
  1008 /// setjmp or other function that gcc recognizes as "returning twice". 
  1009 bool callsFunctionThatReturnsTwice() 
const;
 
  1011 /// Set the attached subprogram. 
  1013 /// Calls \a setMetadata() with \a LLVMContext::MD_dbg. 
  1016 /// Get the attached subprogram. 
  1018 /// Calls \a getMetadata() with \a LLVMContext::MD_dbg and casts the result 
  1019 /// to \a DISubprogram. 
  1022 /// Returns true if we should emit debug info for profiling. 
  1023 bool shouldEmitDebugInfoForProfiling() 
const;
 
  1025 /// Check if null pointer dereferencing is considered undefined behavior for 
  1027 /// Return value: false => null pointer dereference is undefined. 
  1028 /// Return value: true => null pointer dereference is not undefined. 
  1029 bool nullPointerIsDefined() 
const;
 
  1031 /// Returns the alignment of the given function. 
  1033 /// Note that this is the alignment of the code, not the alignment of a 
  1034 /// function pointer. 
  1037 /// Sets the alignment attribute of the Function. 
  1040 /// Sets the alignment attribute of the Function. 
  1042 /// This method will be deprecated as the alignment property should always be 
  1046 /// Return the value for vscale based on the vscale_range attribute or 0 when 
  1048 unsigned getVScaleValue() 
const;
 
  1051 void allocHungoffUselist();
 
  1052 template<
int Idx> 
void setHungoffOperand(
Constant *
C);
 
  1054 /// Shadow Value::setValueSubclassData with a private forwarding method so 
  1055 /// that subclasses cannot accidentally use it. 
  1056 void setValueSubclassData(
unsigned short D) {
 
  1059 void setValueSubclassDataBit(
unsigned Bit, 
bool On);
 
 
  1064// TODO: Need similar function for support of argument in position. General 
  1065// version on FunctionType + Attributes + CallingConv::ID? 
  1067} 
// namespace CallingConv 
  1069/// Check whether null pointer dereferencing is considered undefined behavior 
  1070/// for a given function or an address space. 
  1071/// Null pointer access in non-zero address space is not considered undefined. 
  1072/// Return value: false => null pointer dereference is undefined. 
  1073/// Return value: true => null pointer dereference is not undefined. 
  1080} 
// end namespace llvm 
  1082#endif // LLVM_IR_FUNCTION_H 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
 
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
 
This file contains the simple types necessary to represent the attributes associated with functions a...
 
static bool setDoesNotAccessMemory(Function &F)
 
static bool setMemoryEffects(Function &F, MemoryEffects ME)
 
static bool setOnlyAccessesInaccessibleMemOrArgMem(Function &F)
 
static bool setOnlyAccessesInaccessibleMemory(Function &F)
 
static bool setOnlyAccessesArgMemory(Function &F)
 
static bool setOnlyWritesMemory(Function &F)
 
static bool setOnlyReadsMemory(Function &F)
 
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
 
static void viewCFG(Function &F, const BlockFrequencyInfo *BFI, const BranchProbabilityInfo *BPI, uint64_t MaxFreq, bool CFGOnly=false)
 
SmallVector< BasicBlock *, 8 > BasicBlockListType
 
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&...Args)
 
This file defines the DenseSet and SmallDenseSet classes.
 
II addRangeRetAttr(Range)
 
#define DEFINE_TRANSPARENT_OPERAND_ACCESSORS(CLASS, VALUECLASS)
Macro for generating out-of-class operand accessor definitions.
 
static Type * getValueType(Value *V)
Returns the type of the given value/instruction V.
 
This class represents an incoming formal argument to a Function.
 
This class stores enough information to efficiently remove some attributes from an existing AttrBuild...
 
Functions, function parameters, and return types can have attributes to indicate how they should be t...
 
static LLVM_ABI Attribute getWithUWTableKind(LLVMContext &Context, UWTableKind Kind)
 
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
 
LLVM Basic Block Representation.
 
const Instruction & back() const
 
friend void Instruction::removeFromParent()
 
friend BasicBlock::iterator Instruction::eraseFromParent()
 
const Instruction & front() const
 
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
 
Analysis providing branch probability information.
 
This class represents a range of values.
 
This is an important base class in LLVM.
 
Subprogram description. Uses SubclassData1.
 
A parsed version of the target data layout string in and methods for querying it.
 
Implements a dense probed hash-table based set.
 
Class to represent function types.
 
uint64_t getCount() const
 
ProfileCount(uint64_t Count, ProfileCountType PCT)
 
ProfileCountType getType() const
 
void deleteBody()
deleteBody - This method deletes the body of the function, and converts the linkage to external.
 
void addFnAttr(Attribute::AttrKind Kind)
Add function attributes to this function.
 
const ValueSymbolTable * getValueSymbolTable() const
 
bool isConvergent() const
Determine if the call is convergent.
 
void setCoroDestroyOnlyWhenComplete()
 
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, unsigned AddrSpace, const Twine &N="", Module *M=nullptr)
 
BasicBlock & getEntryBlock()
 
SymbolTableList< BasicBlock > BasicBlockListType
 
void setAlignment(MaybeAlign Align)
Sets the alignment attribute of the Function.
 
void splice(Function::iterator ToIt, Function *FromF)
Transfer all blocks from FromF to this function at ToIt.
 
const BasicBlock & getEntryBlock() const
 
BasicBlockListType::iterator iterator
 
bool hasOptSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
 
void splice(Function::iterator ToIt, Function *FromF, Function::iterator FromIt)
Transfer one BasicBlock from FromF at FromIt to this function at ToIt.
 
FunctionType * getFunctionType() const
Returns the FunctionType for me.
 
bool isMaterializable() const
 
MaybeAlign getAlign() const
Returns the alignment of the given function.
 
MaybeAlign getFnStackAlign() const
Return the stack alignment for the function.
 
iterator_range< const_arg_iterator > args() const
 
static bool classof(const Value *V)
Methods for support type inquiry through isa, cast, and dyn_cast:
 
const BasicBlock & front() const
 
const_arg_iterator arg_end() const
 
const_arg_iterator arg_begin() const
 
bool mustProgress() const
Determine if the function is required to make forward progress.
 
bool returnDoesNotAlias() const
Determine if the parameter or return value is marked with NoAlias attribute.
 
bool cannotDuplicate() const
Determine if the call cannot be duplicated.
 
const BasicBlock & back() const
 
unsigned getMaxBlockNumber() const
Return a value larger than the largest block number.
 
bool willReturn() const
Determine if the function will return.
 
iterator_range< arg_iterator > args()
 
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
 
friend class TargetLibraryInfoImpl
 
bool doesNotRecurse() const
Determine if the function is known not to recurse, directly or indirectly.
 
bool hasMinSize() const
Optimize this function for minimum size (-Oz).
 
bool doesNoCfCheck() const
Determine if the function should not perform indirect branch tracking.
 
void setIsMaterializable(bool V)
 
uint64_t getParamDereferenceableBytes(unsigned ArgNo) const
Extract the number of dereferenceable bytes for a parameter.
 
bool isSpeculatable() const
Determine if the call has sideeffects.
 
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
 
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
 
Type * getParamByValType(unsigned ArgNo) const
Extract the byval type for a parameter.
 
FPClassTest getParamNoFPClass(unsigned ArgNo) const
Extract the nofpclass attribute for a parameter.
 
bool hasPrefixData() const
Check whether this function has prefix data.
 
void setReturnDoesNotAlias()
 
bool hasPersonalityFn() const
Check whether this function has a personality function.
 
void addRetAttr(Attribute::AttrKind Kind)
Add return value attributes to this function.
 
static Function * Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N="", Module *M=nullptr)
 
AttributeList getAttributes() const
Return the attribute list for this Function.
 
void dropAllReferences()
dropAllReferences() - This method causes all the subinstructions to "letgo" of all references that th...
 
unsigned getBlockNumberEpoch() const
Return the "epoch" of current block numbers.
 
void setUWTableKind(UWTableKind K)
 
BasicBlockListType::const_iterator const_iterator
 
UWTableKind getUWTableKind() const
Get what kind of unwind table entry to generate for this function.
 
Type * getParamByRefType(unsigned ArgNo) const
Extract the byref type for a parameter.
 
bool hasNoSync() const
Determine if the call can synchroize with other threads.
 
bool doesNotThrow() const
Determine if the function cannot unwind.
 
const Function & getFunction() const
 
const_iterator end() const
 
uint64_t getParamDereferenceableOrNullBytes(unsigned ArgNo) const
Extract the number of dereferenceable_or_null bytes for a parameter.
 
void removeFnAttr(Attribute::AttrKind Kind)
Remove function attributes from this function.
 
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
 
bool hasProfileData(bool IncludeSynthetic=false) const
Return true if the function is annotated with profile data.
 
const_iterator begin() const
 
void setPresplitCoroutine()
 
void setAlignment(Align Align)
Sets the alignment attribute of the Function.
 
MaybeAlign getParamAlign(unsigned ArgNo) const
 
ValueSymbolTable * getValueSymbolTable()
getSymbolTable() - Return the symbol table if any, otherwise nullptr.
 
bool hasOptNone() const
Do not optimize this function (-O0).
 
void setCannotDuplicate()
 
Type * getParamPreallocatedType(unsigned ArgNo) const
Extract the preallocated type for a parameter.
 
void setAttributes(AttributeList Attrs)
Set the attribute list for this Function.
 
bool isPresplitCoroutine() const
Determine if the function is presplit coroutine.
 
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
 
bool hasKernelCallingConv() const
Does it have a kernel calling convention?
 
bool hasStructRetAttr() const
Determine if the function returns a structure through first or second pointer argument.
 
Function::iterator insert(Function::iterator Position, BasicBlock *BB)
Insert BB in the basic block list at Position.
 
bool doesNotFreeMemory() const
Determine if the call might deallocate memory.
 
Type * getParamInAllocaType(unsigned ArgNo) const
Extract the inalloca type for a parameter.
 
bool doesNotReturn() const
Determine if the function cannot return.
 
friend class InstIterator
 
bool isCoroOnlyDestroyWhenComplete() const
 
std::optional< ProfileCount > getEntryCount(bool AllowSynthetic=false) const
Get the entry count for this function.
 
void setSplittedCoroutine()
 
MaybeAlign getParamStackAlign(unsigned ArgNo) const
 
bool hasUWTable() const
True if the ABI mandates (or the user requested) that this function be in a unwind table.
 
void operator=(const Function &)=delete
 
Type * getReturnType() const
Returns the type of the ret val.
 
bool needsUnwindTableEntry() const
True if this function needs an unwind table.
 
bool hasLazyArguments() const
hasLazyArguments/CheckLazyArguments - The argument list of a function is built on demand,...
 
void setCallingConv(CallingConv::ID CC)
 
Function(const Function &)=delete
 
bool hasPrologueData() const
Check whether this function has prologue data.
 
const Argument * const_arg_iterator
 
Type * getParamStructRetType(unsigned ArgNo) const
Extract the sret type for a parameter.
 
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value)
 
Argument * getArg(unsigned i) const
 
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
 
unsigned getInstructionCount() const
Returns the number of non-debug IR instructions in this function.
 
bool onlyReadsMemory() const
Determine if the function does not access or only reads memory.
 
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
 
void setDoesNotFreeMemory()
 
MaybeAlign getAlign() const
Returns the alignment of the given variable or function.
 
LLVM_ABI void setAlignment(Align Align)
Sets the alignment attribute of the GlobalObject.
 
GlobalObject(Type *Ty, ValueTy VTy, AllocInfo AllocInfo, LinkageTypes Linkage, const Twine &Name, unsigned AddressSpace=0)
 
void setGlobalObjectSubClassData(unsigned Val)
 
unsigned getGlobalObjectSubClassData() const
 
Intrinsic::ID IntID
The intrinsic ID for this subclass (which must be a Function).
 
unsigned HasLLVMReservedName
True if the function's name starts with "llvm.".
 
void setLinkage(LinkageTypes LT)
 
LinkageTypes
An enumeration for the kinds of linkage for global values.
 
@ ExternalLinkage
Externally visible function.
 
This is an important class for using LLVM in a threaded context.
 
A Module instance is used to store all the information related to an LLVM module.
 
StringRef - Represent a constant reference to a string, i.e.
 
List that automatically updates parent links and symbol tables.
 
Implementation of the target library information.
 
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.
 
This class provides a symbol table of name/value pairs.
 
LLVM Value Representation.
 
unsigned short getSubclassDataFromValue() const
 
void setValueSubclassData(unsigned short D)
 
An ilist node that can access its parent list.
 
typename base_list_type::iterator iterator
 
typename base_list_type::const_iterator const_iterator
 
A range adaptor for a pair of iterators.
 
This class implements an extremely fast bulk output stream that can only output to a stream.
 
This file defines the ilist_node class template, which is a convenient base class for creating classe...
 
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
 
CallingConv Namespace - This namespace contains an enum with a value for the well-known calling conve...
 
LLVM_ABI LLVM_READNONE bool supportsNonVoidReturnType(CallingConv::ID CC)
 
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
 
@ AMDGPU_KERNEL
Used for AMDGPU code object kernels.
 
@ MaxID
The highest possible ID. Must be some 2^k - 1.
 
@ SPIR_KERNEL
Used for SPIR kernel functions.
 
@ PTX_Kernel
Call to a PTX kernel. Passes all arguments in parameter space.
 
@ 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.
 
This is an optimization pass for GlobalISel generic memory operations.
 
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
 
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
 
void erase(Container &C, ValueType V)
Wrapper function to remove a value from a container:
 
@ None
No unwind table requested.
 
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
 
LLVM_ABI bool NullPointerIsDefined(const Function *F, unsigned AS=0)
Check whether null pointer dereferencing is considered undefined behavior for a given function or an ...
 
FunctionAddr VTableAddr Count
 
Function::ProfileCount ProfileCount
 
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
 
@ Default
The result values are uniform if and only if all operands are uniform.
 
This struct is a compact representation of a valid (non-zero power of two) alignment.
 
Represent subnormal handling kind for floating point instruction inputs and outputs.
 
HungoffOperandTraits - determine the allocation regime of the Use array when it is not a prefix to th...
 
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
 
Compile-time customization of User operands.
 
Indicates this User has operands "hung off" in another allocation.