LLVM 23.0.0git
BuildLibCalls.cpp File Reference

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "build-libcalls"

Functions

 STATISTIC (NumReadNone, "Number of functions inferred as readnone")
 STATISTIC (NumReadOnly, "Number of functions inferred as readonly")
 STATISTIC (NumWriteOnly, "Number of functions inferred as writeonly")
 STATISTIC (NumArgMemOnly, "Number of functions inferred as argmemonly")
 STATISTIC (NumWriteErrnoMemOnly, "Number of functions inferred as memory(errnomem: write)")
 STATISTIC (NumInaccessibleMemOrArgMemOnly, "Number of functions inferred as inaccessiblemem_or_argmemonly")
 STATISTIC (NumInaccessibleMemOrErrnoMemOnly, "Number of functions inferred as memory(inaccessiblemem: readwrite, " "errnomem: write)")
 STATISTIC (NumInaccessibleMemOrArgMemOrErrnoMemOnly, "Number of functions inferred as memory(argmem: readwrite, " "inaccessiblemem: readwrite, errnomem: write)")
 STATISTIC (NumWriteArgumentMemOrErrnoMemOnly, "Number of functions inferred as memory(argmem: write, errnomem: write)")
 STATISTIC (NumNoUnwind, "Number of functions inferred as nounwind")
 STATISTIC (NumNoCallback, "Number of functions inferred as nocallback")
 STATISTIC (NumNoCapture, "Number of arguments inferred as nocapture")
 STATISTIC (NumWriteOnlyArg, "Number of arguments inferred as writeonly")
 STATISTIC (NumReadOnlyArg, "Number of arguments inferred as readonly")
 STATISTIC (NumNoAlias, "Number of function returns inferred as noalias")
 STATISTIC (NumNoUndef, "Number of function returns inferred as noundef returns")
 STATISTIC (NumReturnedArg, "Number of arguments inferred as returned")
 STATISTIC (NumWillReturn, "Number of functions inferred as willreturn")
 STATISTIC (NumCold, "Number of functions inferred as cold")
 STATISTIC (NumNoReturn, "Number of functions inferred as no return")
static bool setDoesNotAccessMemory (Function &F)
static bool setIsCold (Function &F)
static bool setNoReturn (Function &F)
static bool setMemoryEffects (Function &F, MemoryEffects ME)
static bool setOnlyReadsMemory (Function &F)
static bool setOnlyWritesMemory (Function &F)
static bool setOnlyAccessesArgMemory (Function &F)
static bool setOnlyAccessesInaccessibleMemOrArgMem (Function &F)
static bool setOnlyAccessesInaccessibleMemOrErrnoMem (Function &F)
static bool setOnlyAccessesInaccessibleMemOrArgMemOrErrnoMem (Function &F)
static bool setOnlyWritesErrnoMemory (Function &F)
static bool setOnlyWritesArgMemOrErrnoMem (Function &F)
static bool setDoesNotThrow (Function &F)
static bool setDoesNotCallback (Function &F)
static bool setRetDoesNotAlias (Function &F)
static bool setDoesNotCapture (Function &F, unsigned ArgNo)
static bool setDoesNotAlias (Function &F, unsigned ArgNo)
static bool setOnlyReadsMemory (Function &F, unsigned ArgNo)
static bool setOnlyWritesMemory (Function &F, unsigned ArgNo)
static bool setRetNoUndef (Function &F)
static bool setArgsNoUndef (Function &F)
static bool setArgNoUndef (Function &F, unsigned ArgNo)
static bool setRetAndArgsNoUndef (Function &F)
static bool setReturnedArg (Function &F, unsigned ArgNo)
static bool setNonLazyBind (Function &F)
static bool setDoesNotFreeMemory (Function &F)
static bool setWillReturn (Function &F)
static bool setAlignedAllocParam (Function &F, unsigned ArgNo)
static bool setAllocatedPointerParam (Function &F, unsigned ArgNo)
static bool setAllocSize (Function &F, unsigned ElemSizeArg, std::optional< unsigned > NumElemsArg)
static bool setAllocFamily (Function &F, StringRef Family)
static bool setAllocKind (Function &F, AllocFnKind K)
static void setArgExtAttr (Function &F, unsigned ArgNo, const TargetLibraryInfo &TLI, bool Signed=true)
static void setRetExtAttr (Function &F, const TargetLibraryInfo &TLI, bool Signed=true)
static IntegerTypegetIntTy (IRBuilderBase &B, const TargetLibraryInfo *TLI)
static IntegerTypegetSizeTTy (IRBuilderBase &B, const TargetLibraryInfo *TLI)
static ValueemitLibCall (LibFunc TheLibFunc, Type *ReturnType, ArrayRef< Type * > ParamTypes, ArrayRef< Value * > Operands, IRBuilderBase &B, const TargetLibraryInfo *TLI, bool IsVaArgs=false)
static void appendTypeSuffix (Value *Op, StringRef &Name, SmallString< 20 > &NameBuffer)
 Append a suffix to the function name according to the type of 'Op'.
static ValueemitUnaryFloatFnCallHelper (Value *Op, LibFunc TheLibFunc, StringRef Name, IRBuilderBase &B, const AttributeList &Attrs, const TargetLibraryInfo *TLI)
static ValueemitBinaryFloatFnCallHelper (Value *Op1, Value *Op2, LibFunc TheLibFunc, StringRef Name, IRBuilderBase &B, const AttributeList &Attrs, const TargetLibraryInfo *TLI)

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "build-libcalls"

Definition at line 32 of file BuildLibCalls.cpp.

Function Documentation

◆ appendTypeSuffix()

void appendTypeSuffix ( Value * Op,
StringRef & Name,
SmallString< 20 > & NameBuffer )
static

Append a suffix to the function name according to the type of 'Op'.

Definition at line 1878 of file BuildLibCalls.cpp.

Referenced by llvm::emitBinaryFloatFnCall(), and llvm::emitUnaryFloatFnCall().

◆ emitBinaryFloatFnCallHelper()

◆ emitLibCall()

◆ emitUnaryFloatFnCallHelper()

Value * emitUnaryFloatFnCallHelper ( Value * Op,
LibFunc TheLibFunc,
StringRef Name,
IRBuilderBase & B,
const AttributeList & Attrs,
const TargetLibraryInfo * TLI )
static

◆ getIntTy()

◆ getSizeTTy()

◆ setAlignedAllocParam()

bool setAlignedAllocParam ( Function & F,
unsigned ArgNo )
static

Definition at line 281 of file BuildLibCalls.cpp.

References F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ setAllocatedPointerParam()

bool setAllocatedPointerParam ( Function & F,
unsigned ArgNo )
static

Definition at line 288 of file BuildLibCalls.cpp.

References F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ setAllocFamily()

bool setAllocFamily ( Function & F,
StringRef Family )
static

Definition at line 304 of file BuildLibCalls.cpp.

References F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ setAllocKind()

bool setAllocKind ( Function & F,
AllocFnKind K )
static

Definition at line 311 of file BuildLibCalls.cpp.

References F, and llvm::Attribute::get().

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ setAllocSize()

bool setAllocSize ( Function & F,
unsigned ElemSizeArg,
std::optional< unsigned > NumElemsArg )
static

Definition at line 295 of file BuildLibCalls.cpp.

References F, and llvm::Attribute::getWithAllocSizeArgs().

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ setArgExtAttr()

void setArgExtAttr ( Function & F,
unsigned ArgNo,
const TargetLibraryInfo & TLI,
bool Signed = true )
static

Definition at line 1428 of file BuildLibCalls.cpp.

References F, llvm::Attribute::None, and Signed.

Referenced by llvm::getOrInsertLibFunc().

◆ setArgNoUndef()

bool setArgNoUndef ( Function & F,
unsigned ArgNo )
static

Definition at line 236 of file BuildLibCalls.cpp.

References F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ setArgsNoUndef()

bool setArgsNoUndef ( Function & F)
static

Definition at line 224 of file BuildLibCalls.cpp.

References Changed, and F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs(), and setRetAndArgsNoUndef().

◆ setDoesNotAccessMemory()

bool setDoesNotAccessMemory ( Function & F)
static

Definition at line 65 of file BuildLibCalls.cpp.

References F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ setDoesNotAlias()

bool setDoesNotAlias ( Function & F,
unsigned ArgNo )
static

Definition at line 190 of file BuildLibCalls.cpp.

References F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ setDoesNotCallback()

bool setDoesNotCallback ( Function & F)
static

Definition at line 165 of file BuildLibCalls.cpp.

References F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ setDoesNotCapture()

bool setDoesNotCapture ( Function & F,
unsigned ArgNo )
static

◆ setDoesNotFreeMemory()

bool setDoesNotFreeMemory ( Function & F)
static

Definition at line 266 of file BuildLibCalls.cpp.

References F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ setDoesNotThrow()

bool setDoesNotThrow ( Function & F)
static

Definition at line 157 of file BuildLibCalls.cpp.

References F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ setIsCold()

bool setIsCold ( Function & F)
static

Definition at line 73 of file BuildLibCalls.cpp.

References F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ setMemoryEffects()

◆ setNonLazyBind()

bool setNonLazyBind ( Function & F)
static

Definition at line 259 of file BuildLibCalls.cpp.

References F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs(), and lowerObjCCall().

◆ setNoReturn()

bool setNoReturn ( Function & F)
static

Definition at line 81 of file BuildLibCalls.cpp.

References F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ setOnlyAccessesArgMemory()

bool setOnlyAccessesArgMemory ( Function & F)
static

◆ setOnlyAccessesInaccessibleMemOrArgMem()

bool setOnlyAccessesInaccessibleMemOrArgMem ( Function & F)
static

◆ setOnlyAccessesInaccessibleMemOrArgMemOrErrnoMem()

bool setOnlyAccessesInaccessibleMemOrArgMemOrErrnoMem ( Function & F)
static

◆ setOnlyAccessesInaccessibleMemOrErrnoMem()

bool setOnlyAccessesInaccessibleMemOrErrnoMem ( Function & F)
static

◆ setOnlyReadsMemory() [1/2]

bool setOnlyReadsMemory ( Function & F)
static

◆ setOnlyReadsMemory() [2/2]

bool setOnlyReadsMemory ( Function & F,
unsigned ArgNo )
static

Definition at line 198 of file BuildLibCalls.cpp.

References F.

◆ setOnlyWritesArgMemOrErrnoMem()

bool setOnlyWritesArgMemOrErrnoMem ( Function & F)
static

◆ setOnlyWritesErrnoMemory()

bool setOnlyWritesErrnoMemory ( Function & F)
static

◆ setOnlyWritesMemory() [1/2]

bool setOnlyWritesMemory ( Function & F)
static

◆ setOnlyWritesMemory() [2/2]

bool setOnlyWritesMemory ( Function & F,
unsigned ArgNo )
static

Definition at line 206 of file BuildLibCalls.cpp.

References F.

◆ setRetAndArgsNoUndef()

bool setRetAndArgsNoUndef ( Function & F)
static

Definition at line 244 of file BuildLibCalls.cpp.

References F, setArgsNoUndef(), and setRetNoUndef().

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ setRetDoesNotAlias()

bool setRetDoesNotAlias ( Function & F)
static

Definition at line 173 of file BuildLibCalls.cpp.

References F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ setRetExtAttr()

void setRetExtAttr ( Function & F,
const TargetLibraryInfo & TLI,
bool Signed = true )
static

Definition at line 1435 of file BuildLibCalls.cpp.

References F, llvm::Attribute::None, and Signed.

Referenced by llvm::getOrInsertLibFunc().

◆ setRetNoUndef()

bool setRetNoUndef ( Function & F)
static

Definition at line 214 of file BuildLibCalls.cpp.

References F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs(), and setRetAndArgsNoUndef().

◆ setReturnedArg()

bool setReturnedArg ( Function & F,
unsigned ArgNo )
static

Definition at line 251 of file BuildLibCalls.cpp.

References F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ setWillReturn()

bool setWillReturn ( Function & F)
static

Definition at line 273 of file BuildLibCalls.cpp.

References F.

Referenced by llvm::inferNonMandatoryLibFuncAttrs().

◆ STATISTIC() [1/20]

STATISTIC ( NumArgMemOnly ,
"Number of functions inferred as argmemonly"  )

◆ STATISTIC() [2/20]

STATISTIC ( NumCold ,
"Number of functions inferred as cold"  )

◆ STATISTIC() [3/20]

STATISTIC ( NumInaccessibleMemOrArgMemOnly ,
"Number of functions inferred as inaccessiblemem_or_argmemonly"  )

◆ STATISTIC() [4/20]

STATISTIC ( NumInaccessibleMemOrArgMemOrErrnoMemOnly ,
"Number of functions inferred as memory(argmem: readwrite, " "inaccessiblemem: readwrite, errnomem: write)"  )

◆ STATISTIC() [5/20]

STATISTIC ( NumInaccessibleMemOrErrnoMemOnly ,
"Number of functions inferred as memory(inaccessiblemem: readwrite, " "errnomem: write)"  )

◆ STATISTIC() [6/20]

STATISTIC ( NumNoAlias ,
"Number of function returns inferred as noalias"  )

◆ STATISTIC() [7/20]

STATISTIC ( NumNoCallback ,
"Number of functions inferred as nocallback"  )

◆ STATISTIC() [8/20]

STATISTIC ( NumNoCapture ,
"Number of arguments inferred as nocapture"  )

◆ STATISTIC() [9/20]

STATISTIC ( NumNoReturn ,
"Number of functions inferred as no return"  )

◆ STATISTIC() [10/20]

STATISTIC ( NumNoUndef ,
"Number of function returns inferred as noundef returns"  )

◆ STATISTIC() [11/20]

STATISTIC ( NumNoUnwind ,
"Number of functions inferred as nounwind"  )

◆ STATISTIC() [12/20]

STATISTIC ( NumReadNone ,
"Number of functions inferred as readnone"  )

◆ STATISTIC() [13/20]

STATISTIC ( NumReadOnly ,
"Number of functions inferred as readonly"  )

◆ STATISTIC() [14/20]

STATISTIC ( NumReadOnlyArg ,
"Number of arguments inferred as readonly"  )

◆ STATISTIC() [15/20]

STATISTIC ( NumReturnedArg ,
"Number of arguments inferred as returned"  )

◆ STATISTIC() [16/20]

STATISTIC ( NumWillReturn ,
"Number of functions inferred as willreturn"  )

◆ STATISTIC() [17/20]

STATISTIC ( NumWriteArgumentMemOrErrnoMemOnly ,
"Number of functions inferred as memory(argmem: write, errnomem: write)"  )

◆ STATISTIC() [18/20]

STATISTIC ( NumWriteErrnoMemOnly ,
"Number of functions inferred as memory(errnomem: write)"  )

◆ STATISTIC() [19/20]

STATISTIC ( NumWriteOnly ,
"Number of functions inferred as writeonly"  )

◆ STATISTIC() [20/20]

STATISTIC ( NumWriteOnlyArg ,
"Number of arguments inferred as writeonly"  )