[compiler-rt] [compiler-rt][nsan] Add support for nan detection (PR #101531)
Alexander Shaposhnikov via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 20 11:53:17 PDT 2024
================
@@ -444,6 +444,25 @@ int32_t checkFT(const FT value, ShadowFT Shadow, CheckTypeT CheckType,
const InternalFT check_value = value;
const InternalFT check_shadow = Shadow;
+ // We only check for NaNs in the value, not the shadow.
+ if (flags().check_nan && isnan(check_value)) {
+ GET_CALLER_PC_BP;
+ BufferedStackTrace stack;
+ stack.Unwind(pc, bp, nullptr, false);
+ if (GetSuppressionForStack(&stack, CheckKind::Consistency)) {
+ // FIXME: optionally print.
+ return flags().resume_after_suppression ? kResumeFromValue
+ : kContinueWithShadow;
+ }
+ Decorator D;
+ Printf("%s", D.Warning());
+ Printf("WARNING: NumericalStabilitySanitizer: NaN detected\n");
+ Printf("%s", D.Default());
+ stack.Print();
+ // Performing other tests for NaN values is meaningless when dealing with numbers.
+ return kResumeFromValue;
----------------
alexander-shaposhnikov wrote:
this doesn't respect the option `halt_on_error`, see
```
if (flags().halt_on_error) {
if (common_flags()->abort_on_error)
Printf("ABORTING\n");
else
Printf("Exiting\n");
Die();
}
```
below (lines 575 - 595).
We need the same here + need to test it.
https://github.com/llvm/llvm-project/pull/101531
More information about the llvm-commits
mailing list