diff options
Diffstat (limited to 'llvm/include/llvm/IR/Function.h')
-rw-r--r-- | llvm/include/llvm/IR/Function.h | 40 |
1 files changed, 37 insertions, 3 deletions
diff --git a/llvm/include/llvm/IR/Function.h b/llvm/include/llvm/IR/Function.h index 7e209bb3769b..e0094e2afff2 100644 --- a/llvm/include/llvm/IR/Function.h +++ b/llvm/include/llvm/IR/Function.h @@ -153,6 +153,16 @@ public: static Function *Create(FunctionType *Ty, LinkageTypes Linkage, const Twine &N, Module &M); + /// Creates a function with some attributes recorded in llvm.module.flags + /// applied. + /// + /// Use this when synthesizing new functions that need attributes that would + /// have been set by command line options. + static Function *createWithDefaultAttr(FunctionType *Ty, LinkageTypes Linkage, + unsigned AddrSpace, + const Twine &N = "", + Module *M = nullptr); + // Provide fast operand accessors. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); @@ -426,6 +436,10 @@ public: /// removes the attribute from the list of attributes. void removeParamAttrs(unsigned ArgNo, const AttrBuilder &Attrs); + /// removes noundef and other attributes that imply undefined behavior if a + /// `undef` or `poison` value is passed from the list of attributes. + void removeParamUndefImplyingAttrs(unsigned ArgNo); + /// check if an attributes is in the list of attributes. bool hasAttribute(unsigned i, Attribute::AttrKind Kind) const { return getAttributes().hasAttribute(i, Kind); @@ -479,6 +493,10 @@ public: return AttributeSets.getParamAlignment(ArgNo); } + MaybeAlign getParamStackAlign(unsigned ArgNo) const { + return AttributeSets.getParamStackAlignment(ArgNo); + } + /// Extract the byval type for a parameter. Type *getParamByValType(unsigned ArgNo) const { return AttributeSets.getParamByValType(ArgNo); @@ -489,6 +507,11 @@ public: return AttributeSets.getParamStructRetType(ArgNo); } + /// Extract the inalloca type for a parameter. + Type *getParamInAllocaType(unsigned ArgNo) const { + return AttributeSets.getParamInAllocaType(ArgNo); + } + /// Extract the byref type for a parameter. Type *getParamByRefType(unsigned ArgNo) const { return AttributeSets.getParamByRefType(ArgNo); @@ -624,6 +647,14 @@ public: addFnAttr(Attribute::NoFree); } + /// Determine if the call can synchroize with other threads + bool hasNoSync() const { + return hasFnAttribute(Attribute::NoSync); + } + void setNoSync() { + addFnAttr(Attribute::NoSync); + } + /// Determine if the function is known not to recurse, directly or /// indirectly. bool doesNotRecurse() const { @@ -872,11 +903,14 @@ public: /// hasAddressTaken - returns true if there are any uses of this function /// other than direct calls or invokes to it, or blockaddress expressions. - /// Optionally passes back an offending user for diagnostic purposes and - /// ignores callback uses. + /// Optionally passes back an offending user for diagnostic purposes, + /// ignores callback uses, assume like pointer annotation calls, and + /// references in llvm.used and llvm.compiler.used variables. /// bool hasAddressTaken(const User ** = nullptr, - bool IgnoreCallbackUses = false) const; + bool IgnoreCallbackUses = false, + bool IgnoreAssumeLikeCalls = true, + bool IngoreLLVMUsed = false) const; /// isDefTriviallyDead - Return true if it is trivially safe to remove /// this function definition from the module (because it isn't externally |