|
LLVM 23.0.0git
|
#include "llvm/Transforms/Utils/BuildLibCalls.h"#include "llvm/ADT/SmallString.h"#include "llvm/ADT/Statistic.h"#include "llvm/Analysis/MemoryBuiltins.h"#include "llvm/Analysis/TargetLibraryInfo.h"#include "llvm/IR/Argument.h"#include "llvm/IR/CallingConv.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/DerivedTypes.h"#include "llvm/IR/Function.h"#include "llvm/IR/IRBuilder.h"#include "llvm/IR/Module.h"#include "llvm/IR/Type.h"#include "llvm/Support/TypeSize.h"#include <optional>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 IntegerType * | getIntTy (IRBuilderBase &B, const TargetLibraryInfo *TLI) |
| static IntegerType * | getSizeTTy (IRBuilderBase &B, const TargetLibraryInfo *TLI) |
| static Value * | emitLibCall (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 Value * | emitUnaryFloatFnCallHelper (Value *Op, LibFunc TheLibFunc, StringRef Name, IRBuilderBase &B, const AttributeList &Attrs, const TargetLibraryInfo *TLI) |
| static Value * | emitBinaryFloatFnCallHelper (Value *Op1, Value *Op2, LibFunc TheLibFunc, StringRef Name, IRBuilderBase &B, const AttributeList &Attrs, const TargetLibraryInfo *TLI) |
| #define DEBUG_TYPE "build-libcalls" |
Definition at line 32 of file BuildLibCalls.cpp.
|
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().
|
static |
Definition at line 1940 of file BuildLibCalls.cpp.
References assert(), B(), llvm::dyn_cast(), F, llvm::getOrInsertLibFunc(), llvm::Value::getType(), llvm::inferNonMandatoryLibFuncAttrs(), llvm::CallBase::setAttributes(), and llvm::CallBase::setCallingConv().
Referenced by llvm::emitBinaryFloatFnCall(), and llvm::emitBinaryFloatFnCall().
|
static |
Definition at line 1625 of file BuildLibCalls.cpp.
References B(), llvm::dyn_cast(), F, llvm::FunctionType::get(), llvm::TargetLibraryInfo::getName(), llvm::getOrInsertLibFunc(), llvm::inferNonMandatoryLibFuncAttrs(), llvm::isLibFuncEmittable(), and llvm::CallBase::setCallingConv().
Referenced by llvm::emitBCmp(), llvm::emitMemCCpy(), llvm::emitMemChr(), llvm::emitMemCmp(), llvm::emitMemPCpy(), llvm::emitMemRChr(), llvm::emitSNPrintf(), llvm::emitSPrintf(), llvm::emitStpCpy(), llvm::emitStpNCpy(), llvm::emitStrCat(), llvm::emitStrChr(), llvm::emitStrCpy(), llvm::emitStrDup(), llvm::emitStrLCat(), llvm::emitStrLCpy(), llvm::emitStrLen(), llvm::emitStrNCat(), llvm::emitStrNCmp(), llvm::emitStrNCpy(), llvm::emitVSNPrintf(), llvm::emitVSPrintf(), and llvm::emitWcsLen().
|
static |
Definition at line 1892 of file BuildLibCalls.cpp.
References assert(), B(), llvm::dyn_cast(), F, llvm::getOrInsertLibFunc(), llvm::CallBase::setAttributes(), and llvm::CallBase::setCallingConv().
Referenced by llvm::emitUnaryFloatFnCall(), and llvm::emitUnaryFloatFnCall().
|
static |
Definition at line 1616 of file BuildLibCalls.cpp.
References B(), and llvm::TargetLibraryInfo::getIntSize().
Referenced by llvm::emitBCmp(), llvm::emitFPutC(), llvm::emitFPutS(), llvm::emitMemCCpy(), llvm::emitMemChr(), llvm::emitMemCmp(), llvm::emitMemRChr(), llvm::emitPutChar(), llvm::emitPutS(), llvm::emitSNPrintf(), llvm::emitSPrintf(), llvm::emitStrChr(), llvm::emitStrNCmp(), llvm::emitVSNPrintf(), and llvm::emitVSPrintf().
|
static |
Definition at line 1620 of file BuildLibCalls.cpp.
References B(), and llvm::TargetLibraryInfo::getSizeTSize().
Referenced by llvm::emitBCmp(), llvm::emitCalloc(), llvm::emitFWrite(), llvm::emitMalloc(), llvm::emitMemCCpy(), llvm::emitMemChr(), llvm::emitMemCmp(), llvm::emitMemCpyChk(), llvm::emitMemPCpy(), llvm::emitMemRChr(), llvm::emitSNPrintf(), llvm::emitStpNCpy(), llvm::emitStrLCat(), llvm::emitStrLCpy(), llvm::emitStrLen(), llvm::emitStrNCat(), llvm::emitStrNCmp(), llvm::emitStrNCpy(), llvm::emitVSNPrintf(), and llvm::emitWcsLen().
Definition at line 281 of file BuildLibCalls.cpp.
References F.
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 288 of file BuildLibCalls.cpp.
References F.
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 304 of file BuildLibCalls.cpp.
References F.
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
|
static |
Definition at line 311 of file BuildLibCalls.cpp.
References F, and llvm::Attribute::get().
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
|
static |
Definition at line 295 of file BuildLibCalls.cpp.
References F, and llvm::Attribute::getWithAllocSizeArgs().
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
|
static |
Definition at line 1428 of file BuildLibCalls.cpp.
References F, llvm::Attribute::None, and Signed.
Referenced by llvm::getOrInsertLibFunc().
Definition at line 236 of file BuildLibCalls.cpp.
References F.
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 224 of file BuildLibCalls.cpp.
Referenced by llvm::inferNonMandatoryLibFuncAttrs(), and setRetAndArgsNoUndef().
Definition at line 65 of file BuildLibCalls.cpp.
References F.
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 190 of file BuildLibCalls.cpp.
References F.
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 165 of file BuildLibCalls.cpp.
References F.
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 181 of file BuildLibCalls.cpp.
References F, llvm::Attribute::getWithCaptureInfo(), and llvm::CaptureInfo::none().
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 266 of file BuildLibCalls.cpp.
References F.
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 157 of file BuildLibCalls.cpp.
References F.
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 73 of file BuildLibCalls.cpp.
References F.
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
|
static |
Definition at line 89 of file BuildLibCalls.cpp.
References F.
Referenced by setOnlyAccessesArgMemory(), setOnlyAccessesInaccessibleMemOrArgMem(), setOnlyAccessesInaccessibleMemOrArgMemOrErrnoMem(), setOnlyAccessesInaccessibleMemOrErrnoMem(), setOnlyReadsMemory(), setOnlyWritesArgMemOrErrnoMem(), setOnlyWritesErrnoMemory(), and setOnlyWritesMemory().
Definition at line 259 of file BuildLibCalls.cpp.
References F.
Referenced by llvm::inferNonMandatoryLibFuncAttrs(), and lowerObjCCall().
Definition at line 81 of file BuildLibCalls.cpp.
References F.
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 112 of file BuildLibCalls.cpp.
References llvm::MemoryEffectsBase< IRMemLocation >::argMemOnly(), F, and setMemoryEffects().
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 119 of file BuildLibCalls.cpp.
References F, llvm::MemoryEffectsBase< IRMemLocation >::inaccessibleOrArgMemOnly(), and setMemoryEffects().
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 134 of file BuildLibCalls.cpp.
References F, llvm::MemoryEffectsBase< IRMemLocation >::inaccessibleOrArgOrErrnoMemOnly(), llvm::Mod, llvm::ModRef, and setMemoryEffects().
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 126 of file BuildLibCalls.cpp.
References F, llvm::MemoryEffectsBase< IRMemLocation >::inaccessibleOrErrnoMemOnly(), llvm::Mod, llvm::ModRef, and setMemoryEffects().
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 98 of file BuildLibCalls.cpp.
References F, llvm::MemoryEffectsBase< IRMemLocation >::readOnly(), and setMemoryEffects().
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 198 of file BuildLibCalls.cpp.
References F.
Definition at line 149 of file BuildLibCalls.cpp.
References llvm::MemoryEffectsBase< IRMemLocation >::argumentOrErrnoMemOnly(), F, llvm::Mod, and setMemoryEffects().
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 142 of file BuildLibCalls.cpp.
References llvm::MemoryEffectsBase< IRMemLocation >::errnoMemOnly(), F, llvm::Mod, and setMemoryEffects().
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 105 of file BuildLibCalls.cpp.
References F, setMemoryEffects(), and llvm::MemoryEffectsBase< IRMemLocation >::writeOnly().
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 206 of file BuildLibCalls.cpp.
References F.
Definition at line 244 of file BuildLibCalls.cpp.
References F, setArgsNoUndef(), and setRetNoUndef().
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 173 of file BuildLibCalls.cpp.
References F.
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
|
static |
Definition at line 1435 of file BuildLibCalls.cpp.
References F, llvm::Attribute::None, and Signed.
Referenced by llvm::getOrInsertLibFunc().
Definition at line 214 of file BuildLibCalls.cpp.
References F.
Referenced by llvm::inferNonMandatoryLibFuncAttrs(), and setRetAndArgsNoUndef().
Definition at line 251 of file BuildLibCalls.cpp.
References F.
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
Definition at line 273 of file BuildLibCalls.cpp.
References F.
Referenced by llvm::inferNonMandatoryLibFuncAttrs().
| STATISTIC | ( | NumArgMemOnly | , |
| "Number of functions inferred as argmemonly" | ) |
| STATISTIC | ( | NumCold | , |
| "Number of functions inferred as cold" | ) |
| STATISTIC | ( | NumInaccessibleMemOrArgMemOnly | , |
| "Number of functions inferred as inaccessiblemem_or_argmemonly" | ) |
| STATISTIC | ( | NumInaccessibleMemOrArgMemOrErrnoMemOnly | , |
| "Number of functions inferred as memory(argmem: readwrite, " "inaccessiblemem: readwrite, errnomem: write)" | ) |
| STATISTIC | ( | NumInaccessibleMemOrErrnoMemOnly | , |
| "Number of functions inferred as memory(inaccessiblemem: readwrite, " "errnomem: write)" | ) |
| STATISTIC | ( | NumNoAlias | , |
| "Number of function returns inferred as noalias" | ) |
| STATISTIC | ( | NumNoCallback | , |
| "Number of functions inferred as nocallback" | ) |
| STATISTIC | ( | NumNoCapture | , |
| "Number of arguments inferred as nocapture" | ) |
| STATISTIC | ( | NumNoReturn | , |
| "Number of functions inferred as no return" | ) |
| STATISTIC | ( | NumNoUndef | , |
| "Number of function returns inferred as noundef returns" | ) |
| STATISTIC | ( | NumNoUnwind | , |
| "Number of functions inferred as nounwind" | ) |
| STATISTIC | ( | NumReadNone | , |
| "Number of functions inferred as readnone" | ) |
| STATISTIC | ( | NumReadOnly | , |
| "Number of functions inferred as readonly" | ) |
| STATISTIC | ( | NumReadOnlyArg | , |
| "Number of arguments inferred as readonly" | ) |
| STATISTIC | ( | NumReturnedArg | , |
| "Number of arguments inferred as returned" | ) |
| STATISTIC | ( | NumWillReturn | , |
| "Number of functions inferred as willreturn" | ) |
| STATISTIC | ( | NumWriteArgumentMemOrErrnoMemOnly | , |
| "Number of functions inferred as memory(argmem: write, errnomem: write)" | ) |
| STATISTIC | ( | NumWriteOnly | , |
| "Number of functions inferred as writeonly" | ) |
| STATISTIC | ( | NumWriteOnlyArg | , |
| "Number of arguments inferred as writeonly" | ) |