LLVM 20.0.0git
|
#include "llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Regex.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/Instrumentation.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
#include <cstdint>
Go to the source code of this file.
Macros | |
#define | DEBUG_TYPE "nsan" |
#define | MOVE_FLAG(attr, setter) |
Enumerations | |
enum class | ContinuationType { ContinueWithShadow = 0 , ResumeFromValue = 1 } |
Functions | |
STATISTIC (NumInstrumentedFTLoads, "Number of instrumented floating-point loads") | |
STATISTIC (NumInstrumentedFTCalls, "Number of instrumented floating-point calls") | |
STATISTIC (NumInstrumentedFTRets, "Number of instrumented floating-point returns") | |
STATISTIC (NumInstrumentedFTStores, "Number of instrumented floating-point stores") | |
STATISTIC (NumInstrumentedNonFTStores, "Number of instrumented non floating-point stores") | |
STATISTIC (NumInstrumentedNonFTMemcpyStores, "Number of instrumented non floating-point stores with memcpy semantics") | |
STATISTIC (NumInstrumentedFCmp, "Number of instrumented fcmps") | |
constexpr StringLiteral | kNsanModuleCtorName ("nsan.module_ctor") |
constexpr StringLiteral | kNsanInitName ("__nsan_init") |
static GlobalValue * | createThreadLocalGV (const char *Name, Module &M, Type *Ty) |
static bool | shouldCheckArgs (CallBase &CI, const TargetLibraryInfo &TLI, const std::optional< Regex > &CheckFunctionsFilter) |
static FunctionType * | makeDoubleDouble (LLVMContext &C) |
static FunctionType * | makeX86FP80X86FP80 (LLVMContext &C) |
static FunctionType * | makeDoubleDoubleI32 (LLVMContext &C) |
static FunctionType * | makeX86FP80X86FP80I32 (LLVMContext &C) |
static FunctionType * | makeDoubleDoubleDouble (LLVMContext &C) |
static FunctionType * | makeX86FP80X86FP80X86FP80 (LLVMContext &C) |
static FunctionType * | makeDoubleDoubleDoubleDouble (LLVMContext &C) |
static FunctionType * | makeX86FP80X86FP80X86FP80X86FP80 (LLVMContext &C) |
static const char * | getIntrinsicFromLibfunc (Function &Fn, Type *VT, const TargetLibraryInfo &TLI) |
static void | moveFastMathFlags (Function &F, std::vector< Instruction * > &Instructions) |
static uint64_t | GetMemOpSize (Value *V) |
Variables | |
static cl::opt< std::string > | ClShadowMapping ("nsan-shadow-type-mapping", cl::init("dqq"), cl::desc("One shadow type id for each of `float`, `double`, `long double`. " "`d`,`l`,`q`,`e` mean double, x86_fp80, fp128 (quad) and " "ppc_fp128 (extended double) respectively. The default is to " "shadow `float` as `double`, and `double` and `x86_fp80` as " "`fp128`"), cl::Hidden) |
static cl::opt< bool > | ClInstrumentFCmp ("nsan-instrument-fcmp", cl::init(true), cl::desc("Instrument floating-point comparisons"), cl::Hidden) |
static cl::opt< std::string > | ClCheckFunctionsFilter ("check-functions-filter", cl::desc("Only emit checks for arguments of functions " "whose names match the given regular expression"), cl::value_desc("regex")) |
static cl::opt< bool > | ClTruncateFCmpEq ("nsan-truncate-fcmp-eq", cl::init(true), cl::desc("This flag controls the behaviour of fcmp equality comparisons." "For equality comparisons such as `x == 0.0f`, we can perform the " "shadow check in the shadow (`x_shadow == 0.0) == (x == 0.0f)`) or app " " domain (`(trunc(x_shadow) == 0.0f) == (x == 0.0f)`). This helps " "catch the case when `x_shadow` is accurate enough (and therefore " "close enough to zero) so that `trunc(x_shadow)` is zero even though " "both `x` and `x_shadow` are not"), cl::Hidden) |
static cl::opt< bool > | ClCheckLoads ("nsan-check-loads", cl::desc("Check floating-point load"), cl::Hidden) |
static cl::opt< bool > | ClCheckStores ("nsan-check-stores", cl::init(true), cl::desc("Check floating-point stores"), cl::Hidden) |
static cl::opt< bool > | ClCheckRet ("nsan-check-ret", cl::init(true), cl::desc("Check floating-point return values"), cl::Hidden) |
static cl::opt< bool > | ClPropagateNonFTConstStoresAsFT ("nsan-propagate-non-ft-const-stores-as-ft", cl::desc("Propagate non floating-point const stores as floating point values." "For debugging purposes only"), cl::Hidden) |
constexpr int | kShadowScale = 2 |
constexpr int | kMaxVectorWidth = 8 |
constexpr int | kMaxNumArgs = 128 |
constexpr int | kMaxShadowTypeSizeBytes = 16 |
#define DEBUG_TYPE "nsan" |
Definition at line 47 of file NumericalStabilitySanitizer.cpp.
#define MOVE_FLAG | ( | attr, | |
setter | |||
) |
|
strong |
Enumerator | |
---|---|
ContinueWithShadow | |
ResumeFromValue |
Definition at line 889 of file NumericalStabilitySanitizer.cpp.
|
static |
Definition at line 646 of file NumericalStabilitySanitizer.cpp.
References Name.
|
static |
Definition at line 1537 of file NumericalStabilitySanitizer.cpp.
References llvm::errs(), llvm::TargetLibraryInfo::getLibFunc(), llvm::TargetLibraryInfo::getName(), LLVM_DEBUG, and Name.
Definition at line 2186 of file NumericalStabilitySanitizer.cpp.
References llvm::CallingConv::C.
|
constexpr |
Referenced by llvm::NumericalStabilitySanitizerPass::run().
|
constexpr |
Referenced by llvm::NumericalStabilitySanitizerPass::run().
|
static |
Definition at line 1317 of file NumericalStabilitySanitizer.cpp.
References llvm::CallingConv::C, and llvm::Type::getDoubleTy().
|
static |
Definition at line 1337 of file NumericalStabilitySanitizer.cpp.
References llvm::CallingConv::C, and llvm::Type::getDoubleTy().
|
static |
Definition at line 1348 of file NumericalStabilitySanitizer.cpp.
References llvm::CallingConv::C, and llvm::Type::getDoubleTy().
|
static |
Definition at line 1326 of file NumericalStabilitySanitizer.cpp.
References llvm::CallingConv::C, llvm::Type::getDoubleTy(), and llvm::Type::getInt32Ty().
|
static |
Definition at line 1321 of file NumericalStabilitySanitizer.cpp.
References llvm::CallingConv::C, and llvm::Type::getX86_FP80Ty().
|
static |
Definition at line 1331 of file NumericalStabilitySanitizer.cpp.
References llvm::CallingConv::C, llvm::Type::getInt32Ty(), and llvm::Type::getX86_FP80Ty().
|
static |
Definition at line 1342 of file NumericalStabilitySanitizer.cpp.
References llvm::CallingConv::C, and llvm::Type::getX86_FP80Ty().
|
static |
Definition at line 1355 of file NumericalStabilitySanitizer.cpp.
References llvm::CallingConv::C, and llvm::Type::getX86_FP80Ty().
|
static |
Definition at line 2016 of file NumericalStabilitySanitizer.cpp.
References llvm::CallingConv::Fast, I, and MOVE_FLAG.
|
static |
Definition at line 793 of file NumericalStabilitySanitizer.cpp.
References llvm::CallBase::getCalledFunction(), llvm::Function::getIntrinsicID(), llvm::TargetLibraryInfo::getLibFunc(), llvm::Value::getName(), llvm::StringRef::starts_with(), and llvm::Value::users().
STATISTIC | ( | NumInstrumentedFCmp | , |
"Number of instrumented fcmps" | |||
) |
STATISTIC | ( | NumInstrumentedFTCalls | , |
"Number of instrumented floating-point calls" | |||
) |
STATISTIC | ( | NumInstrumentedFTLoads | , |
"Number of instrumented floating-point loads" | |||
) |
STATISTIC | ( | NumInstrumentedFTRets | , |
"Number of instrumented floating-point returns" | |||
) |
STATISTIC | ( | NumInstrumentedFTStores | , |
"Number of instrumented floating-point stores" | |||
) |
STATISTIC | ( | NumInstrumentedNonFTMemcpyStores | , |
"Number of instrumented non floating-point stores with memcpy semantics" | |||
) |
STATISTIC | ( | NumInstrumentedNonFTStores | , |
"Number of instrumented non floating-point stores" | |||
) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
constexpr |
Definition at line 140 of file NumericalStabilitySanitizer.cpp.
|
constexpr |
Definition at line 141 of file NumericalStabilitySanitizer.cpp.
|
constexpr |
Definition at line 139 of file NumericalStabilitySanitizer.cpp.
|
constexpr |
Definition at line 138 of file NumericalStabilitySanitizer.cpp.