LLVM: lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp File Reference (original) (raw)

Go to the source code of this file.

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

DEBUG_TYPE

#define DEBUG_TYPE "nsan"

MOVE_FLAG

| #define MOVE_FLAG | ( | | attr, | | ------------------ | - | | ----- | | | setter | | | | | ) | | | |

Value:

if (F.getFnAttribute(attr).getValueAsString() == "true") { \

F.removeFnAttr(attr); \

FMF.set##setter(); \

}

ContinuationType

createThreadLocalGV()

getIntrinsicFromLibfunc()

GetMemOpSize()

kNsanInitName()

constexpr StringLiteral kNsanInitName ( "__nsan_init" ) constexpr

kNsanModuleCtorName()

constexpr StringLiteral kNsanModuleCtorName ( "nsan.module_ctor" ) constexpr

makeDoubleDouble()

makeDoubleDoubleDouble()

makeDoubleDoubleDoubleDouble()

makeDoubleDoubleI32()

makeX86FP80X86FP80()

makeX86FP80X86FP80I32()

makeX86FP80X86FP80X86FP80()

makeX86FP80X86FP80X86FP80X86FP80()

moveFastMathFlags()

static void moveFastMathFlags ( Function & F, std::vector< Instruction * > & Instructions ) static

shouldCheckArgs()

STATISTIC() [1/7]

STATISTIC ( NumInstrumentedFCmp ,
"Number of instrumented fcmps"
)

STATISTIC() [2/7]

STATISTIC ( NumInstrumentedFTCalls ,
"Number of instrumented floating-point calls"
)

STATISTIC() [3/7]

STATISTIC ( NumInstrumentedFTLoads ,
"Number of instrumented floating-point loads"
)

STATISTIC() [4/7]

STATISTIC ( NumInstrumentedFTRets ,
"Number of instrumented floating-point returns"
)

STATISTIC() [5/7]

STATISTIC ( NumInstrumentedFTStores ,
"Number of instrumented floating-point stores"
)

STATISTIC() [6/7]

STATISTIC ( NumInstrumentedNonFTMemcpyStores ,
"Number of instrumented non floating-point stores with memcpy semantics"
)

STATISTIC() [7/7]

STATISTIC ( NumInstrumentedNonFTStores ,
"Number of instrumented non floating-point stores"
)

ClCheckFunctionsFilter

ClCheckLoads

cl::opt< bool > ClCheckLoads("nsan-check-loads", cl::desc("Check floating-point load"), cl::Hidden) ( "nsan-check-loads" , cl::desc("Check floating-point load") , cl::Hidden ) static

ClCheckRet

cl::opt< bool > ClCheckRet("nsan-check-ret", cl::init(true), cl::desc("Check floating-point return values"), cl::Hidden) ( "nsan-check-ret" , cl::init(true) , cl::desc("Check floating-point return values") , cl::Hidden ) static

ClCheckStores

cl::opt< bool > ClCheckStores("nsan-check-stores", cl::init(true), cl::desc("Check floating-point stores"), cl::Hidden) ( "nsan-check-stores" , cl::init(true) , cl::desc("Check floating-point stores") , cl::Hidden ) static

ClInstrumentFCmp

ClPropagateNonFTConstStoresAsFT

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) ( "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 ) static

ClShadowMapping

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) ( "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

ClTruncateFCmpEq

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) ( "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" ) static

kMaxNumArgs

constexpr int kMaxNumArgs = 128 constexpr

kMaxShadowTypeSizeBytes

constexpr int kMaxShadowTypeSizeBytes = 16 constexpr

kMaxVectorWidth

constexpr int kMaxVectorWidth = 8 constexpr

kShadowScale

constexpr int kShadowScale = 2 constexpr