Skip to content

[LLVM][Instrumentation] Add numerical sanitizer #85916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 28, 2024

Conversation

alexander-shaposhnikov
Copy link
Collaborator

@alexander-shaposhnikov alexander-shaposhnikov commented Mar 20, 2024

This PR introduces the numerical sanitizer originally proposed by Clement Courbet on https://reviews.llvm.org/D97854
(https://arxiv.org/abs/2102.12782).

The main additions include:

  • Migration to LLVM opaque pointers
  • Migration to various updated APIs
  • Extended coverage for LLVM instructions/intrinsics, that enabled us to have a green run of tests again

The tool is still very experimental, the coverage (e.g. for intrinsics / library functions) is incomplete.

Test plan:

  1. ninja check-all
  2. ninja check-nsan

@llvmbot llvmbot added clang Clang issues not falling into any other category compiler-rt clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang:frontend Language frontend issues, e.g. anything involving "Sema" clang:codegen IR generation bugs: mangling, exceptions, etc. compiler-rt:sanitizer llvm:ir llvm:transforms labels Mar 20, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 20, 2024

@llvm/pr-subscribers-clang
@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-clang-driver
@llvm/pr-subscribers-compiler-rt-sanitizer
@llvm/pr-subscribers-llvm-ir

@llvm/pr-subscribers-clang-codegen

Author: Alexander Shaposhnikov (alexander-shaposhnikov)

Changes

This PR introduces the numerical sanitizer originally proposed by Clement Courbet on https://reviews.llvm.org/D97854
(https://arxiv.org/abs/2102.12782).

The main additions include:

  • Migration to LLVM opaque pointers
  • Migration to various updated APIs
  • Extended coverage for LLVM instructions/intrinsics, that enabled us to have a green run of tests again

Patch is 344.35 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/85916.diff

77 Files Affected:

  • (modified) clang/include/clang/Basic/Features.def (+1)
  • (modified) clang/include/clang/Basic/Sanitizers.def (+3)
  • (modified) clang/include/clang/Driver/SanitizerArgs.h (+3)
  • (modified) clang/lib/CodeGen/BackendUtil.cpp (+7)
  • (modified) clang/lib/CodeGen/CGDeclCXX.cpp (+4)
  • (modified) clang/lib/CodeGen/CodeGenFunction.cpp (+2)
  • (modified) clang/lib/Driver/SanitizerArgs.cpp (+5-2)
  • (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+3)
  • (modified) clang/lib/Driver/ToolChains/Linux.cpp (+4)
  • (modified) clang/runtime/CMakeLists.txt (+2-1)
  • (modified) compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake (+1)
  • (modified) compiler-rt/cmake/config-ix.cmake (+12-1)
  • (added) compiler-rt/include/sanitizer/nsan_interface.h (+75)
  • (added) compiler-rt/lib/nsan/CMakeLists.txt (+61)
  • (added) compiler-rt/lib/nsan/nsan.cc (+828)
  • (added) compiler-rt/lib/nsan/nsan.h (+224)
  • (added) compiler-rt/lib/nsan/nsan.syms.extra (+2)
  • (added) compiler-rt/lib/nsan/nsan_flags.cc (+78)
  • (added) compiler-rt/lib/nsan/nsan_flags.h (+35)
  • (added) compiler-rt/lib/nsan/nsan_flags.inc (+49)
  • (added) compiler-rt/lib/nsan/nsan_interceptors.cc (+363)
  • (added) compiler-rt/lib/nsan/nsan_platform.h (+135)
  • (added) compiler-rt/lib/nsan/nsan_stats.cc (+158)
  • (added) compiler-rt/lib/nsan/nsan_stats.h (+92)
  • (added) compiler-rt/lib/nsan/nsan_suppressions.cc (+76)
  • (added) compiler-rt/lib/nsan/nsan_suppressions.h (+31)
  • (added) compiler-rt/lib/nsan/tests/CMakeLists.txt (+54)
  • (added) compiler-rt/lib/nsan/tests/NSanUnitTest.cpp (+67)
  • (added) compiler-rt/lib/nsan/tests/nsan_unit_test_main.cpp (+18)
  • (added) compiler-rt/test/nsan/CMakeLists.txt (+33)
  • (added) compiler-rt/test/nsan/alloca.cc (+24)
  • (added) compiler-rt/test/nsan/cadna_ex1.cc (+21)
  • (added) compiler-rt/test/nsan/cadna_ex2.cc (+52)
  • (added) compiler-rt/test/nsan/cadna_ex3.cc (+48)
  • (added) compiler-rt/test/nsan/cadna_ex4.cc (+37)
  • (added) compiler-rt/test/nsan/cadna_ex5.cc (+97)
  • (added) compiler-rt/test/nsan/cadna_ex6.cc (+67)
  • (added) compiler-rt/test/nsan/cadna_ex7.cc (+110)
  • (added) compiler-rt/test/nsan/cancellation_fn_ptr.cc (+66)
  • (added) compiler-rt/test/nsan/cancellation_libm.cc (+51)
  • (added) compiler-rt/test/nsan/cancellation_ok.cc (+53)
  • (added) compiler-rt/test/nsan/compare.cc (+28)
  • (added) compiler-rt/test/nsan/compute_pi.cc (+45)
  • (added) compiler-rt/test/nsan/helpers.h (+15)
  • (added) compiler-rt/test/nsan/infinity.cc (+24)
  • (added) compiler-rt/test/nsan/intercept_libc_str.cc (+149)
  • (added) compiler-rt/test/nsan/interface_dump_shadow_mem.cc (+62)
  • (added) compiler-rt/test/nsan/jmmuller.cc (+35)
  • (added) compiler-rt/test/nsan/lit.cfg.py (+45)
  • (added) compiler-rt/test/nsan/lit.site.cfg.py.in (+11)
  • (added) compiler-rt/test/nsan/memcpy.cc (+83)
  • (added) compiler-rt/test/nsan/memset_nonzero.cc (+23)
  • (added) compiler-rt/test/nsan/memset_zero.cc (+24)
  • (added) compiler-rt/test/nsan/rump_royal_pain.cc (+37)
  • (added) compiler-rt/test/nsan/simd.cc (+25)
  • (added) compiler-rt/test/nsan/stable_sort.cc (+52)
  • (added) compiler-rt/test/nsan/stack.cc (+20)
  • (added) compiler-rt/test/nsan/sums.cc (+82)
  • (added) compiler-rt/test/nsan/swap.cc (+46)
  • (added) compiler-rt/test/nsan/type_punning.cc (+26)
  • (added) compiler-rt/test/nsan/uninstrumented_write.cc (+22)
  • (added) compiler-rt/test/nsan/vector_push_back.cc (+17)
  • (added) compiler-rt/test/nsan/verificarlo_case4.cc (+29)
  • (modified) llvm/include/llvm/Bitcode/LLVMBitCodes.h (+1)
  • (modified) llvm/include/llvm/IR/Attributes.td (+4)
  • (added) llvm/include/llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h (+40)
  • (modified) llvm/lib/Bitcode/Reader/BitcodeReader.cpp (+2)
  • (modified) llvm/lib/Bitcode/Writer/BitcodeWriter.cpp (+2)
  • (modified) llvm/lib/Passes/PassBuilder.cpp (+1)
  • (modified) llvm/lib/Passes/PassRegistry.def (+2)
  • (modified) llvm/lib/Transforms/Instrumentation/CMakeLists.txt (+1)
  • (added) llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp (+2261)
  • (modified) llvm/lib/Transforms/Utils/CodeExtractor.cpp (+1)
  • (added) llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll (+930)
  • (added) llvm/test/Instrumentation/NumericalStabilitySanitizer/cfg.ll (+113)
  • (added) llvm/test/Instrumentation/NumericalStabilitySanitizer/invoke.ll (+148)
  • (added) llvm/test/Instrumentation/NumericalStabilitySanitizer/memory.ll (+405)
diff --git a/clang/include/clang/Basic/Features.def b/clang/include/clang/Basic/Features.def
index eeed5f4751f2f4..c75bc2475ef74d 100644
--- a/clang/include/clang/Basic/Features.def
+++ b/clang/include/clang/Basic/Features.def
@@ -102,6 +102,7 @@ FEATURE(thread_sanitizer, LangOpts.Sanitize.has(SanitizerKind::Thread))
 FEATURE(dataflow_sanitizer, LangOpts.Sanitize.has(SanitizerKind::DataFlow))
 FEATURE(scudo, LangOpts.Sanitize.hasOneOf(SanitizerKind::Scudo))
 FEATURE(ptrauth_intrinsics, LangOpts.PointerAuthIntrinsics)
+FEATURE(numericalstability_sanitizer, LangOpts.Sanitize.has(SanitizerKind::NumericalStability))
 FEATURE(swiftasynccc,
   PP.getTargetInfo().checkCallingConvention(CC_SwiftAsync) ==
   clang::TargetInfo::CCCR_OK)
diff --git a/clang/include/clang/Basic/Sanitizers.def b/clang/include/clang/Basic/Sanitizers.def
index c2137e3f61f645..5f6249523e1d10 100644
--- a/clang/include/clang/Basic/Sanitizers.def
+++ b/clang/include/clang/Basic/Sanitizers.def
@@ -76,6 +76,9 @@ SANITIZER("fuzzer-no-link", FuzzerNoLink)
 // ThreadSanitizer
 SANITIZER("thread", Thread)
 
+// Numerical stability sanitizer.
+SANITIZER("numerical", NumericalStability)
+
 // LeakSanitizer
 SANITIZER("leak", Leak)
 
diff --git a/clang/include/clang/Driver/SanitizerArgs.h b/clang/include/clang/Driver/SanitizerArgs.h
index 07070ec4fc0653..47ef175302679f 100644
--- a/clang/include/clang/Driver/SanitizerArgs.h
+++ b/clang/include/clang/Driver/SanitizerArgs.h
@@ -103,6 +103,9 @@ class SanitizerArgs {
   bool needsCfiDiagRt() const;
   bool needsStatsRt() const { return Stats; }
   bool needsScudoRt() const { return Sanitizers.has(SanitizerKind::Scudo); }
+  bool needsNsanRt() const {
+    return Sanitizers.has(SanitizerKind::NumericalStability);
+  }
 
   bool hasMemTag() const {
     return hasMemtagHeap() || hasMemtagStack() || hasMemtagGlobals();
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 82b30b8d815629..9ae3d3a6f82e73 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -75,6 +75,7 @@
 #include "llvm/Transforms/Instrumentation/KCFI.h"
 #include "llvm/Transforms/Instrumentation/MemProfiler.h"
 #include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
+#include "llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h"
 #include "llvm/Transforms/Instrumentation/PGOInstrumentation.h"
 #include "llvm/Transforms/Instrumentation/RemoveTrapsPass.h"
 #include "llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h"
@@ -734,6 +735,12 @@ static void addSanitizers(const Triple &TargetTriple,
     if (LangOpts.Sanitize.has(SanitizerKind::DataFlow)) {
       MPM.addPass(DataFlowSanitizerPass(LangOpts.NoSanitizeFiles));
     }
+
+    if (LangOpts.Sanitize.has(SanitizerKind::NumericalStability)) {
+      MPM.addPass(NumericalStabilitySanitizerPass());
+      MPM.addPass(
+          createModuleToFunctionPassAdaptor(NumericalStabilitySanitizerPass()));
+    }
   };
   if (ClSanitizeOnOptimizerEarlyEP) {
     PB.registerOptimizerEarlyEPCallback(
diff --git a/clang/lib/CodeGen/CGDeclCXX.cpp b/clang/lib/CodeGen/CGDeclCXX.cpp
index e08a1e5f42df20..70e45e8f322a52 100644
--- a/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -476,6 +476,10 @@ llvm::Function *CodeGenModule::CreateGlobalInitOrCleanUpFunction(
       !isInNoSanitizeList(SanitizerKind::Thread, Fn, Loc))
     Fn->addFnAttr(llvm::Attribute::SanitizeThread);
 
+  if (getLangOpts().Sanitize.has(SanitizerKind::NumericalStability) &&
+      !isInNoSanitizeList(SanitizerKind::NumericalStability, Fn, Loc))
+    Fn->addFnAttr(llvm::Attribute::SanitizeNumericalStability);
+
   if (getLangOpts().Sanitize.has(SanitizerKind::Memory) &&
       !isInNoSanitizeList(SanitizerKind::Memory, Fn, Loc))
     Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index fad26c43da3d34..c2522708a83641 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -795,6 +795,8 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
       Fn->addFnAttr(llvm::Attribute::SanitizeMemTag);
     if (SanOpts.has(SanitizerKind::Thread))
       Fn->addFnAttr(llvm::Attribute::SanitizeThread);
+    if (SanOpts.has(SanitizerKind::NumericalStability))
+      Fn->addFnAttr(llvm::Attribute::SanitizeNumericalStability);
     if (SanOpts.hasOneOf(SanitizerKind::Memory | SanitizerKind::KernelMemory))
       Fn->addFnAttr(llvm::Attribute::SanitizeMemory);
   }
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index 8bfe9f02a091d1..52b5345bd3ddc4 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -41,7 +41,8 @@ static const SanitizerMask NotAllowedWithExecuteOnly =
     SanitizerKind::Function | SanitizerKind::KCFI;
 static const SanitizerMask NeedsUnwindTables =
     SanitizerKind::Address | SanitizerKind::HWAddress | SanitizerKind::Thread |
-    SanitizerKind::Memory | SanitizerKind::DataFlow;
+    SanitizerKind::Memory | SanitizerKind::DataFlow |
+    SanitizerKind::NumericalStability;
 static const SanitizerMask SupportsCoverage =
     SanitizerKind::Address | SanitizerKind::HWAddress |
     SanitizerKind::KernelAddress | SanitizerKind::KernelHWAddress |
@@ -53,7 +54,8 @@ static const SanitizerMask SupportsCoverage =
     SanitizerKind::DataFlow | SanitizerKind::Fuzzer |
     SanitizerKind::FuzzerNoLink | SanitizerKind::FloatDivideByZero |
     SanitizerKind::SafeStack | SanitizerKind::ShadowCallStack |
-    SanitizerKind::Thread | SanitizerKind::ObjCCast | SanitizerKind::KCFI;
+    SanitizerKind::Thread | SanitizerKind::ObjCCast | SanitizerKind::KCFI |
+    SanitizerKind::NumericalStability;
 static const SanitizerMask RecoverableByDefault =
     SanitizerKind::Undefined | SanitizerKind::Integer |
     SanitizerKind::ImplicitConversion | SanitizerKind::Nullability |
@@ -175,6 +177,7 @@ static void addDefaultIgnorelists(const Driver &D, SanitizerMask Kinds,
                      {"hwasan_ignorelist.txt", SanitizerKind::HWAddress},
                      {"memtag_ignorelist.txt", SanitizerKind::MemTag},
                      {"msan_ignorelist.txt", SanitizerKind::Memory},
+                     {"nsan_ignorelist.txt", SanitizerKind::NumericalStability},
                      {"tsan_ignorelist.txt", SanitizerKind::Thread},
                      {"dfsan_abilist.txt", SanitizerKind::DataFlow},
                      {"cfi_ignorelist.txt", SanitizerKind::CFI},
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 4478865313636d..f09af3f251b511 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1526,11 +1526,14 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
     if (SanArgs.linkCXXRuntimes())
       StaticRuntimes.push_back("msan_cxx");
   }
+  if (SanArgs.needsNsanRt())
+    StaticRuntimes.push_back("nsan");
   if (!SanArgs.needsSharedRt() && SanArgs.needsTsanRt()) {
     StaticRuntimes.push_back("tsan");
     if (SanArgs.linkCXXRuntimes())
       StaticRuntimes.push_back("tsan_cxx");
   }
+
   if (!SanArgs.needsSharedRt() && SanArgs.needsUbsanRt()) {
     if (SanArgs.requiresMinimalRuntime()) {
       StaticRuntimes.push_back("ubsan_minimal");
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index 6c2f23e57bce05..7ad1df71ae9fef 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -825,6 +825,10 @@ SanitizerMask Linux::getSupportedSanitizers() const {
   if (IsX86_64 || IsAArch64) {
     Res |= SanitizerKind::KernelHWAddress;
   }
+  if (IsX86_64) {
+    Res |= SanitizerKind::NumericalStability;
+  }
+
   // Work around "Cannot represent a difference across sections".
   if (getTriple().getArch() == llvm::Triple::ppc64)
     Res &= ~SanitizerKind::Function;
diff --git a/clang/runtime/CMakeLists.txt b/clang/runtime/CMakeLists.txt
index 65fcdc2868f031..0248655d1df931 100644
--- a/clang/runtime/CMakeLists.txt
+++ b/clang/runtime/CMakeLists.txt
@@ -122,7 +122,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)
                            COMPONENT compiler-rt)
 
   # Add top-level targets that build specific compiler-rt runtimes.
-  set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan profile tsan ubsan ubsan-minimal)
+  set(COMPILER_RT_RUNTIMES fuzzer asan builtins dfsan lsan msan nsan profile tsan ubsan ubsan-minimal)
   foreach(runtime ${COMPILER_RT_RUNTIMES})
     get_ext_project_build_command(build_runtime_cmd ${runtime})
     add_custom_target(${runtime}
@@ -149,6 +149,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS ${COMPILER_RT_SRC_ROOT}/)
         check-hwasan
         check-lsan
         check-msan
+        check-nsan
         check-profile
         check-safestack
         check-sanitizer
diff --git a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
index 423171532c2028..304ebd8f1fe737 100644
--- a/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
+++ b/compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
@@ -61,6 +61,7 @@ else()
 endif()
 set(ALL_MSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64} ${PPC64} ${S390X}
     ${LOONGARCH64})
+set(ALL_NSAN_SUPPORTED_ARCH ${X86} ${X86_64})
 set(ALL_HWASAN_SUPPORTED_ARCH ${X86_64} ${ARM64} ${RISCV64})
 set(ALL_MEMPROF_SUPPORTED_ARCH ${X86_64})
 set(ALL_PROFILE_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${PPC32} ${PPC64}
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index 4f47142850a55e..2430ed55dc5829 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -621,6 +621,9 @@ if(APPLE)
   list_intersect(MSAN_SUPPORTED_ARCH
     ALL_MSAN_SUPPORTED_ARCH
     SANITIZER_COMMON_SUPPORTED_ARCH)
+  list_intersect(NSAN_SUPPORTED_ARCH
+    ALL_NSAN_SUPPORTED_ARCH
+    SANITIZER_COMMON_SUPPORTED_ARCH)
   list_intersect(HWASAN_SUPPORTED_ARCH
     ALL_HWASAN_SUPPORTED_ARCH
     SANITIZER_COMMON_SUPPORTED_ARCH)
@@ -686,6 +689,7 @@ else()
   filter_available_targets(SHADOWCALLSTACK_SUPPORTED_ARCH
     ${ALL_SHADOWCALLSTACK_SUPPORTED_ARCH})
   filter_available_targets(GWP_ASAN_SUPPORTED_ARCH ${ALL_GWP_ASAN_SUPPORTED_ARCH})
+  filter_available_targets(NSAN_SUPPORTED_ARCH ${ALL_NSAN_SUPPORTED_ARCH})
   filter_available_targets(ORC_SUPPORTED_ARCH ${ALL_ORC_SUPPORTED_ARCH})
 endif()
 
@@ -720,7 +724,7 @@ if(COMPILER_RT_SUPPORTED_ARCH)
 endif()
 message(STATUS "Compiler-RT supported architectures: ${COMPILER_RT_SUPPORTED_ARCH}")
 
-set(ALL_SANITIZERS asan;dfsan;msan;hwasan;tsan;safestack;cfi;scudo_standalone;ubsan_minimal;gwp_asan;asan_abi)
+set(ALL_SANITIZERS asan;dfsan;msan;hwasan;tsan;safestack;cfi;scudo_standalone;ubsan_minimal;gwp_asan;nsan;asan_abi)
 set(COMPILER_RT_SANITIZERS_TO_BUILD all CACHE STRING
     "sanitizers to build if supported on the target (all;${ALL_SANITIZERS})")
 list_replace(COMPILER_RT_SANITIZERS_TO_BUILD all "${ALL_SANITIZERS}")
@@ -898,4 +902,11 @@ if (GWP_ASAN_SUPPORTED_ARCH AND
 else()
   set(COMPILER_RT_HAS_GWP_ASAN FALSE)
 endif()
+
+if (COMPILER_RT_HAS_SANITIZER_COMMON AND NSAN_SUPPORTED_ARCH AND
+    OS_NAME MATCHES "Linux")
+  set(COMPILER_RT_HAS_NSAN TRUE)
+else()
+  set(COMPILER_RT_HAS_NSAN FALSE)
+endif()
 pythonize_bool(COMPILER_RT_HAS_GWP_ASAN)
diff --git a/compiler-rt/include/sanitizer/nsan_interface.h b/compiler-rt/include/sanitizer/nsan_interface.h
new file mode 100644
index 00000000000000..057ca0473bb3c6
--- /dev/null
+++ b/compiler-rt/include/sanitizer/nsan_interface.h
@@ -0,0 +1,75 @@
+//===-- sanitizer/nsan_interface.h ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Public interface for nsan.
+//
+//===----------------------------------------------------------------------===//
+#ifndef SANITIZER_NSAN_INTERFACE_H
+#define SANITIZER_NSAN_INTERFACE_H
+
+#include <sanitizer/common_interface_defs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/// User-provided default option settings.
+///
+/// You can provide your own implementation of this function to return a string
+/// containing NSan runtime options (for example,
+/// <c>verbosity=1:halt_on_error=0</c>).
+///
+/// \returns Default options string.
+const char *__nsan_default_options(void);
+
+// Dumps nsan shadow data for a block of `size_bytes` bytes of application
+// memory at location `addr`.
+//
+// Each line contains application address, shadow types, then values.
+// Unknown types are shown as `__`, while known values are shown as
+// `f`, `d`, `l` for float, double, and long double respectively. Position is
+// shown as a single hex digit. The shadow value itself appears on the line that
+// contains the first byte of the value.
+// FIXME: Show both shadow and application value.
+//
+// Example: `__nsan_dump_shadow_mem(addr, 32, 8, 0)` might print:
+//
+//  0x0add7359:  __ f0 f1 f2 f3 __ __ __   (42.000)
+//  0x0add7361:  __ d1 d2 d3 d4 d5 d6 d7
+//  0x0add7369:  d8 f0 f1 f2 f3 __ __ f2   (-1.000) (12.5)
+//  0x0add7371:  f3 __ __ __ __ __ __ __
+//
+// This means that there is:
+//   - a shadow double for the float at address 0x0add7360, with value 42;
+//   - a shadow float128 for the double at address 0x0add7362, with value -1;
+//   - a shadow double for the float at address 0x0add736a, with value 12.5;
+// There was also a shadow double for the float at address 0x0add736e, but bytes
+// f0 and f1 were overwritten by one or several stores, so that the shadow value
+// is no longer valid.
+// The argument `reserved` can be any value. Its true value is provided by the
+// instrumentation.
+void __nsan_dump_shadow_mem(const char *addr, size_t size_bytes,
+                            size_t bytes_per_line, size_t reserved);
+
+// Explicitly dumps a value.
+// FIXME: vector versions ?
+void __nsan_dump_float(float value);
+void __nsan_dump_double(double value);
+void __nsan_dump_longdouble(long double value);
+
+// Explicitly checks a value.
+// FIXME: vector versions ?
+void __nsan_check_float(float value);
+void __nsan_check_double(double value);
+void __nsan_check_longdouble(long double value);
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // SANITIZER_NSAN_INTERFACE_H
diff --git a/compiler-rt/lib/nsan/CMakeLists.txt b/compiler-rt/lib/nsan/CMakeLists.txt
new file mode 100644
index 00000000000000..00b16473bff0ef
--- /dev/null
+++ b/compiler-rt/lib/nsan/CMakeLists.txt
@@ -0,0 +1,61 @@
+add_compiler_rt_component(nsan)
+
+include_directories(..)
+
+set(NSAN_SOURCES
+  nsan.cc
+  nsan_flags.cc
+  nsan_interceptors.cc
+  nsan_stats.cc
+  nsan_suppressions.cc
+)
+
+set(NSAN_HEADERS
+  nsan.h
+  nsan_flags.h
+  nsan_flags.inc
+  nsan_platform.h
+  nsan_stats.h
+  nsan_suppressions.h
+)
+
+append_list_if(COMPILER_RT_HAS_FPIC_FLAG -fPIC NSAN_CFLAGS)
+
+set(NSAN_DYNAMIC_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS})
+
+set(NSAN_CFLAGS ${SANITIZER_COMMON_CFLAGS})
+#-fno-rtti -fno-exceptions
+#    -nostdinc++ -pthread -fno-omit-frame-pointer)
+
+# Remove -stdlib= which is unused when passing -nostdinc++.
+# string(REGEX REPLACE "-stdlib=[a-zA-Z+]*" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+
+if (COMPILER_RT_HAS_NSAN)
+  foreach(arch ${NSAN_SUPPORTED_ARCH})
+    add_compiler_rt_runtime(
+      clang_rt.nsan
+      STATIC
+      ARCHS ${arch}
+      SOURCES ${NSAN_SOURCES}
+              $<TARGET_OBJECTS:RTInterception.${arch}>
+              $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
+              $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
+              $<TARGET_OBJECTS:RTSanitizerCommonCoverage.${arch}>
+              $<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
+              $<TARGET_OBJECTS:RTUbsan.${arch}>
+      ADDITIONAL_HEADERS ${NSAN_HEADERS}
+      CFLAGS ${NSAN_CFLAGS}
+      PARENT_TARGET nsan
+    )
+  endforeach()
+
+  add_compiler_rt_object_libraries(RTNsan
+      ARCHS ${NSAN_SUPPORTED_ARCH}
+      SOURCES ${NSAN_SOURCES}
+      ADDITIONAL_HEADERS ${NSAN_HEADERS}
+      CFLAGS ${NSAN_CFLAGS})
+endif()
+
+if(COMPILER_RT_INCLUDE_TESTS)
+  add_subdirectory(tests)
+endif()
diff --git a/compiler-rt/lib/nsan/nsan.cc b/compiler-rt/lib/nsan/nsan.cc
new file mode 100644
index 00000000000000..29351ca111a3ff
--- /dev/null
+++ b/compiler-rt/lib/nsan/nsan.cc
@@ -0,0 +1,828 @@
+//===-- nsan.cc -----------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// NumericalStabilitySanitizer runtime.
+//
+// This implements:
+//  - The public nsan interface (include/sanitizer/nsan_interface.h).
+//  - The private nsan interface (./nsan.h).
+//  - The internal instrumentation interface. These are function emitted by the
+//    instrumentation pass:
+//        * __nsan_get_shadow_ptr_for_{float,double,longdouble}_load
+//          These return the shadow memory pointer for loading the shadow value,
+//          after checking that the types are consistent. If the types are not
+//          consistent, returns nullptr.
+//        * __nsan_get_shadow_ptr_for_{float,double,longdouble}_store
+//          Sets the shadow types appropriately and returns the shadow memory
+//          pointer for storing the shadow value.
+//        * __nsan_internal_check_{float,double,long double}_{f,d,l} checks the
+//          accuracy of a value against its shadow and emits a warning depending
+//          on the runtime configuration. The middle part indicates the type of
+//          the application value, the suffix (f,d,l) indicates the type of the
+//          shadow, and depends on the instrumentation configuration.
+//        * __nsan_fcmp_fail_* emits a warning for an fcmp instruction whose
+//          corresponding shadow fcmp result differs.
+//
+//===----------------------------------------------------------------------===//
+
+#include <assert.h>
+#include <math.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "sanitizer_common/sanitizer_atomic.h"
+#include "sanitizer_common/sanitizer_common.h"
+#include "sanitizer_common/sanitizer_libc.h"
+#include "sanitizer_common/sanitizer_report_decorator.h"
+#include "sanitizer_common/sanitizer_stacktrace.h"
+#include "sanitizer_common/sanitizer_symbolizer.h"
+
+#include "nsan/nsan.h"
+#include "nsan/nsan_flags.h"
+#include "nsan/nsan_stats.h"
+#include "nsan/nsan_suppressions.h"
+
+using namespace __sanitizer;
+using namespace __nsan;
+
+static constexpr const int kMaxVectorWidth = 8;
+
+// When copying application memory, we also copy its shadow and shadow type.
+// FIXME: We could provide fixed-size versions that would nicely
+// vectorize for known sizes.
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
+__nsan_copy_values(const char *daddr, const char *saddr, uptr size) {
+  internal_memmove((void *)getShadowTypeAddrFor(daddr),
+                   getShadowTypeAddrFor(saddr), size);
+  internal_memmove((void *)getShadowAddrFor(daddr), getShadowAddrFor(saddr),
+                   size * kShadowScale);
+}
+
+// FIXME: We could provide fixed-size versions that would nicely
+// vectorize for known sizes.
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void
+__nsan_set_value_unknown(const char *addr, uptr size) {
+  internal_memset((void *)getShadowTypeAddrFor(addr), 0, size);
+}
+
+namespace __nsan {
+
+const char *FTInfo<float>::kCppTypeName = "float";
+const char *FTInfo<double>::kCppTypeName = "double";
+const char *FTInfo<long double>::kCppTypeName = "long double";
+const char *FTInfo<__float128>::kCppTypeName = "__float128";
+
+const char FTInfo<float>::kTypePattern[sizeof(float)];
+const char FTInfo<double>::kTypePattern[sizeof(double)];
+const char FTInfo<long double>::kTypePattern[sizeof(long double)];
+
+// Helper for __nsan_dump_shadow_mem: Reads the value at address `Ptr`,
+// identified by its type id.
+template <ty...
[truncated]

Copy link

github-actions bot commented Mar 20, 2024

✅ With the latest revision this PR passed the Python code formatter.

@vitalybuka
Copy link
Collaborator

Can we split the patch into smaller pieces?
e.g. clang, transform, runtime ?

This one has transform, comments, so we can keep it for transform.

@vitalybuka
Copy link
Collaborator

vitalybuka commented Mar 26, 2024

clang changes LGTM, but they are missing tests

@alexander-shaposhnikov
Copy link
Collaborator Author

@vitalybuka , @arsenm - thanks a lot, yeah, sure, I can split the patch.
P.S. will update/address comments soon.

Copy link

github-actions bot commented May 13, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff d4f5cf267936a082196b0c22fe45c730b24b9fe0 bc248edaa5a2669eadec85178208a99c93a8dec1 -- llvm/include/llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp llvm/include/llvm/Bitcode/LLVMBitCodes.h llvm/lib/Bitcode/Reader/BitcodeReader.cpp llvm/lib/Bitcode/Writer/BitcodeWriter.cpp llvm/lib/Passes/PassBuilder.cpp llvm/lib/Transforms/Utils/CodeExtractor.cpp
View the diff from clang-format here.
diff --git a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
index 8d5be4cb3c..9cf93ecfef 100644
--- a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
@@ -1245,8 +1245,7 @@ Value *NumericalStabilitySanitizer::handleExt(FPExtInst &Ext, Type *VT,
   //     fpext double  %1 to x86_fp80  ->  fpext float    s(%1) to double
 
   // See (A) above.
-  Value *Source =
-      ExtendedSourceTy ? Map.getShadow(OrigSource) : OrigSource;
+  Value *Source = ExtendedSourceTy ? Map.getShadow(OrigSource) : OrigSource;
   Type *SourceTy = ExtendedSourceTy ? ExtendedSourceTy : OrigSourceTy;
   // See (B) above.
   if (SourceTy == ExtendedVT)

@alexander-shaposhnikov
Copy link
Collaborator Author

@arsenm , @vitalybuka : I've split out the changes to clang and compiler-rt from this PR.
Addressed comments (except one).

@alexander-shaposhnikov alexander-shaposhnikov force-pushed the rebased_nsan branch 2 times, most recently from 3c21e54 to ca29922 Compare May 15, 2024 05:54
@alexander-shaposhnikov alexander-shaposhnikov force-pushed the rebased_nsan branch 2 times, most recently from 61fc96c to d5e671f Compare June 24, 2024 20:20
@alexander-shaposhnikov alexander-shaposhnikov force-pushed the rebased_nsan branch 2 times, most recently from 6452d9b to 729dfc2 Compare June 25, 2024 22:17
};

const KnownIntrinsic::LFEntry KnownIntrinsic::kLibfuncIntrinsics[] = {
{LibFunc_sqrtf, "llvm.sqrt.f32"}, //
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete //?

}

const KnownIntrinsic::WidenedIntrinsic *KnownIntrinsic::widen(StringRef Name) {
for (const auto &E : kWidenedIntrinsics) {
Copy link
Member

@MaskRay MaskRay Jun 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kWidenedIntrinsics is long and string comparison is not that fast. perhaps a static local densemap<stringref, xxx> that is lazily initialized

Value *ICmpEQ = Builder.CreateICmpEQ(
CheckResult,
ConstantInt::get(Builder.getInt32Ty(),
static_cast<int>(ContinuationType::ResumeFromValue)));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResumeFromValue is 1. Testing it is slightly slower than testing 0 (ContinueWithShadow)

Copy link
Member

@MaskRay MaskRay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a few nits, then I realized that I can just publish https://github.com/MaskRay/llvm-project/tree/nsan The top commit contains code style changes.

std::optional<Regex> CheckFunctionsFilter;
};

void insertModuleCtor(Module &M) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static void instead of an anonymous namespace per https://llvm.org/docs/CodingStandards.html#anonymous-namespaces


bool NumericalStabilitySanitizer::sanitizeFunction(
Function &F, const TargetLibraryInfo &TLI) {
if (F.empty() || !F.hasFnAttribute(Attribute::SanitizeNumericalStability))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unused condition F.empty()


static Instruction *getNextInstructionOrDie(Instruction &Inst) {
assert(Inst.getNextNode() && "instruction is a terminator");
return Inst.getNextNode();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helper function does not seem useful. IRBuilder crashes when the parameter is null.

Value *getShadow(Value *V) const {
if (Constant *C = dyn_cast<Constant>(V))
return getShadowConstant(C);
const auto ShadowValIt = Map.find(V);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Map.find(V)->second

The dereference makes assert redundant.

@alexander-shaposhnikov alexander-shaposhnikov merged commit 15ad791 into llvm:main Jun 28, 2024
4 of 6 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 28, 2024

LLVM Buildbot has detected a new failure on builder clang-ve-ninja running on hpce-ve-main while building llvm at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/12/builds/919

Here is the relevant piece of the build log for the reference:

Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/ve-linux.py ...' (failure)
...
[633/634] Running the LLVM regression tests
Unknown option: -C
usage: git [--version] [--help] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]
An error occurred retrieving the git revision: Command '['git', '-C', '/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm', 'rev-parse', 'HEAD']' returned non-zero exit status 129.
-- Testing: 54291 tests, 48 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.
FAIL: LLVM :: Instrumentation/NumericalStabilitySanitizer/basic.ll (30476 of 54291)
******************** TEST 'LLVM :: Instrumentation/NumericalStabilitySanitizer/basic.ll' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 2: /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/opt -passes=nsan -nsan-shadow-type-mapping=dqq -nsan-truncate-fcmp-eq=false -S /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll | /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll --check-prefixes=CHECK,DQQ
+ /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll --check-prefixes=CHECK,DQQ
+ /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/opt -passes=nsan -nsan-shadow-type-mapping=dqq -nsan-truncate-fcmp-eq=false -S /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/opt -passes=nsan -nsan-shadow-type-mapping=dqq -nsan-truncate-fcmp-eq=false -S /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll
1.	Running pass "nsan" on module "/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll"
 #0 0x0000000002489357 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13
 #1 0x0000000002487510 llvm::sys::RunSignalHandlers() /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Support/Signals.cpp:106:18
 #2 0x0000000002489a1f SignalHandler(int) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #3 0x00007f8bc33b7630 __restore_rt sigaction.c:0:0
 #4 0x00000000022bd551 llvm::Type::isVoidTy() const /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/include/llvm/IR/Type.h:140:46
 #5 0x00000000022bd551 llvm::Intrinsic::getType(llvm::LLVMContext&, unsigned int, llvm::ArrayRef<llvm::Type*>) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/IR/Function.cpp:1466:41
 #6 0x00000000022bf2af llvm::Intrinsic::getDeclaration(llvm::Module*, unsigned int, llvm::ArrayRef<llvm::Type*>) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/IR/Function.cpp:1487:14
 #7 0x00000000022c66ca llvm::IRBuilderBase::createCallHelper(llvm::Function*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&, llvm::Instruction*, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*>>) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/IR/IRBuilder.cpp:0:0
 #8 0x00000000022c66ca llvm::IRBuilderBase::CreateIntrinsic(unsigned int, llvm::ArrayRef<llvm::Type*>, llvm::ArrayRef<llvm::Value*>, llvm::Instruction*, llvm::Twine const&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/IR/IRBuilder.cpp:939:10
 #9 0x0000000001677568 (anonymous namespace)::NumericalStabilitySanitizer::maybeHandleKnownCallBase(llvm::CallBase&, llvm::Type*, llvm::Type*, llvm::TargetLibraryInfo const&, (anonymous namespace)::ValueToShadowMap const&, llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp:1557:34
#10 0x0000000001677568 (anonymous namespace)::NumericalStabilitySanitizer::handleCallBase(llvm::CallBase&, llvm::Type*, llvm::Type*, llvm::TargetLibraryInfo const&, (anonymous namespace)::ValueToShadowMap const&, llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp:1578:11
#11 0x0000000001672026 (anonymous namespace)::NumericalStabilitySanitizer::createShadowValueWithOperandsAvailable(llvm::Instruction&, llvm::TargetLibraryInfo const&, (anonymous namespace)::ValueToShadowMap const&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp:1615:12
#12 0x0000000001672026 (anonymous namespace)::NumericalStabilitySanitizer::maybeCreateShadowValue(llvm::Instruction&, llvm::TargetLibraryInfo const&, (anonymous namespace)::ValueToShadowMap&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp:1730:21
#13 0x000000000166f591 __gnu_cxx::__normal_iterator<llvm::Instruction**, std::vector<llvm::Instruction*, std::allocator<llvm::Instruction*>>>::operator++() /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/stl_iterator.h:1005:2
#14 0x000000000166f591 (anonymous namespace)::NumericalStabilitySanitizer::sanitizeFunction(llvm::Function&, llvm::TargetLibraryInfo const&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp:2094:23
#15 0x000000000166f591 llvm::NumericalStabilitySanitizerPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp:584:10
#16 0x0000000000eb4dad llvm::detail::PassModel<llvm::Module, llvm::NumericalStabilitySanitizerPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:90:5
#17 0x0000000002328d76 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:79:8
#18 0x000000000075b9f6 llvm::SmallPtrSetImplBase::isSmall() const /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:197:33
#19 0x000000000075b9f6 llvm::SmallPtrSetImplBase::~SmallPtrSetImplBase() /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:84:10
#20 0x000000000075b9f6 llvm::PreservedAnalyses::~PreservedAnalyses() /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/include/llvm/IR/Analysis.h:111:7
#21 0x000000000075b9f6 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/tools/opt/NewPMDriver.cpp:547:3
#22 0x000000000075106b optMain /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/tools/opt/optdriver.cpp:739:12
#23 0x000000000074baca main /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/tools/opt/opt.cpp:25:35
#24 0x00007f8bc23d0555 __libc_start_main /usr/src/debug/glibc-2.17-c758a686/csu/../csu/libc-start.c:300:0
#25 0x000000000074ba07 _start (/scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/opt+0x74ba07)
Step 8 (check-llvm) failure: check-llvm (failure)
...
[633/634] Running the LLVM regression tests
Unknown option: -C
usage: git [--version] [--help] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]
An error occurred retrieving the git revision: Command '['git', '-C', '/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm', 'rev-parse', 'HEAD']' returned non-zero exit status 129.
-- Testing: 54291 tests, 48 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.
FAIL: LLVM :: Instrumentation/NumericalStabilitySanitizer/basic.ll (30476 of 54291)
******************** TEST 'LLVM :: Instrumentation/NumericalStabilitySanitizer/basic.ll' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 2: /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/opt -passes=nsan -nsan-shadow-type-mapping=dqq -nsan-truncate-fcmp-eq=false -S /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll | /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll --check-prefixes=CHECK,DQQ
+ /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/FileCheck /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll --check-prefixes=CHECK,DQQ
+ /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/opt -passes=nsan -nsan-shadow-type-mapping=dqq -nsan-truncate-fcmp-eq=false -S /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/opt -passes=nsan -nsan-shadow-type-mapping=dqq -nsan-truncate-fcmp-eq=false -S /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll
1.	Running pass "nsan" on module "/scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll"
 #0 0x0000000002489357 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13
 #1 0x0000000002487510 llvm::sys::RunSignalHandlers() /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Support/Signals.cpp:106:18
 #2 0x0000000002489a1f SignalHandler(int) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #3 0x00007f8bc33b7630 __restore_rt sigaction.c:0:0
 #4 0x00000000022bd551 llvm::Type::isVoidTy() const /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/include/llvm/IR/Type.h:140:46
 #5 0x00000000022bd551 llvm::Intrinsic::getType(llvm::LLVMContext&, unsigned int, llvm::ArrayRef<llvm::Type*>) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/IR/Function.cpp:1466:41
 #6 0x00000000022bf2af llvm::Intrinsic::getDeclaration(llvm::Module*, unsigned int, llvm::ArrayRef<llvm::Type*>) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/IR/Function.cpp:1487:14
 #7 0x00000000022c66ca llvm::IRBuilderBase::createCallHelper(llvm::Function*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&, llvm::Instruction*, llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*>>) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/IR/IRBuilder.cpp:0:0
 #8 0x00000000022c66ca llvm::IRBuilderBase::CreateIntrinsic(unsigned int, llvm::ArrayRef<llvm::Type*>, llvm::ArrayRef<llvm::Value*>, llvm::Instruction*, llvm::Twine const&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/IR/IRBuilder.cpp:939:10
 #9 0x0000000001677568 (anonymous namespace)::NumericalStabilitySanitizer::maybeHandleKnownCallBase(llvm::CallBase&, llvm::Type*, llvm::Type*, llvm::TargetLibraryInfo const&, (anonymous namespace)::ValueToShadowMap const&, llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp:1557:34
#10 0x0000000001677568 (anonymous namespace)::NumericalStabilitySanitizer::handleCallBase(llvm::CallBase&, llvm::Type*, llvm::Type*, llvm::TargetLibraryInfo const&, (anonymous namespace)::ValueToShadowMap const&, llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp:1578:11
#11 0x0000000001672026 (anonymous namespace)::NumericalStabilitySanitizer::createShadowValueWithOperandsAvailable(llvm::Instruction&, llvm::TargetLibraryInfo const&, (anonymous namespace)::ValueToShadowMap const&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp:1615:12
#12 0x0000000001672026 (anonymous namespace)::NumericalStabilitySanitizer::maybeCreateShadowValue(llvm::Instruction&, llvm::TargetLibraryInfo const&, (anonymous namespace)::ValueToShadowMap&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp:1730:21
#13 0x000000000166f591 __gnu_cxx::__normal_iterator<llvm::Instruction**, std::vector<llvm::Instruction*, std::allocator<llvm::Instruction*>>>::operator++() /opt/rh/devtoolset-10/root/usr/lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/stl_iterator.h:1005:2
#14 0x000000000166f591 (anonymous namespace)::NumericalStabilitySanitizer::sanitizeFunction(llvm::Function&, llvm::TargetLibraryInfo const&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp:2094:23
#15 0x000000000166f591 llvm::NumericalStabilitySanitizerPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp:584:10
#16 0x0000000000eb4dad llvm::detail::PassModel<llvm::Module, llvm::NumericalStabilitySanitizerPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/include/llvm/IR/PassManagerInternal.h:90:5
#17 0x0000000002328d76 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/include/llvm/IR/PassManagerImpl.h:79:8
#18 0x000000000075b9f6 llvm::SmallPtrSetImplBase::isSmall() const /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:197:33
#19 0x000000000075b9f6 llvm::SmallPtrSetImplBase::~SmallPtrSetImplBase() /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/include/llvm/ADT/SmallPtrSet.h:84:10
#20 0x000000000075b9f6 llvm::PreservedAnalyses::~PreservedAnalyses() /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/include/llvm/IR/Analysis.h:111:7
#21 0x000000000075b9f6 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/tools/opt/NewPMDriver.cpp:547:3
#22 0x000000000075106b optMain /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/tools/opt/optdriver.cpp:739:12
#23 0x000000000074baca main /scratch/buildbot/bothome/clang-ve-ninja/llvm-project/llvm/tools/opt/opt.cpp:25:35
#24 0x00007f8bc23d0555 __libc_start_main /usr/src/debug/glibc-2.17-c758a686/csu/../csu/libc-start.c:300:0
#25 0x000000000074ba07 _start (/scratch/buildbot/bothome/clang-ve-ninja/build/build_llvm/bin/opt+0x74ba07)

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 28, 2024

LLVM Buildbot has detected a new failure on builder fuchsia-x86_64-linux running on fuchsia-debian-64-us-central1-a-1 while building llvm at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/11/builds/822

Here is the relevant piece of the build log for the reference:

Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure)
...
[1409/1414] Building CXX object unittests/Transforms/Scalar/CMakeFiles/ScalarTests.dir/LoopPassManagerTest.cpp.o
clang++: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument]
[1410/1414] Linking CXX executable unittests/Transforms/Scalar/ScalarTests
[1410/1414] Running the LLVM regression tests
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld.lld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/ld.lld
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using lld-link: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/lld-link
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld64.lld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/ld64.lld
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using wasm-ld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/wasm-ld
-- Testing: 54601 tests, 60 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50
FAIL: LLVM :: Instrumentation/NumericalStabilitySanitizer/basic.ll (30030 of 54601)
******************** TEST 'LLVM :: Instrumentation/NumericalStabilitySanitizer/basic.ll' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 2: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/opt -passes=nsan -nsan-shadow-type-mapping=dqq -nsan-truncate-fcmp-eq=false -S /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll | /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll --check-prefixes=CHECK,DQQ
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll --check-prefixes=CHECK,DQQ
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/opt -passes=nsan -nsan-shadow-type-mapping=dqq -nsan-truncate-fcmp-eq=false -S /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll --check-prefixes=CHECK,DQQ

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
********************
Failed Tests (1):
  LLVM :: Instrumentation/NumericalStabilitySanitizer/basic.ll


Testing Time: 73.15s

Total Discovered Tests: 60233
  Skipped          :    33 (0.05%)
  Unsupported      : 16416 (27.25%)
  Passed           : 43717 (72.58%)
  Expectedly Failed:    66 (0.11%)
  Failed           :     1 (0.00%)
[1411/1414] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/SourceCodeTest.cpp.o
clang++: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument]
[1412/1414] Linking CXX executable tools/clang/unittests/Tooling/ToolingTests
FAILED: test/CMakeFiles/check-llvm /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/test/CMakeFiles/check-llvm 
cd /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/test && /usr/bin/python3.10 /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/./bin/llvm-lit -sv /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/test
ninja: build stopped: subcommand failed.
['ninja', '-C', '/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt', 'check-llvm', 'check-clang', 'check-lld'] exited with return code 1.
@@@STEP_FAILURE@@@
Step 7 (check) failure: check (failure)
...
[1409/1414] Building CXX object unittests/Transforms/Scalar/CMakeFiles/ScalarTests.dir/LoopPassManagerTest.cpp.o
clang++: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument]
[1410/1414] Linking CXX executable unittests/Transforms/Scalar/ScalarTests
[1410/1414] Running the LLVM regression tests
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld.lld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/ld.lld
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using lld-link: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/lld-link
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using ld64.lld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/ld64.lld
llvm-lit: /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:508: note: using wasm-ld: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/wasm-ld
-- Testing: 54601 tests, 60 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50
FAIL: LLVM :: Instrumentation/NumericalStabilitySanitizer/basic.ll (30030 of 54601)
******************** TEST 'LLVM :: Instrumentation/NumericalStabilitySanitizer/basic.ll' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 2: /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/opt -passes=nsan -nsan-shadow-type-mapping=dqq -nsan-truncate-fcmp-eq=false -S /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll | /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll --check-prefixes=CHECK,DQQ
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll --check-prefixes=CHECK,DQQ
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/opt -passes=nsan -nsan-shadow-type-mapping=dqq -nsan-truncate-fcmp-eq=false -S /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/bin/FileCheck /var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll --check-prefixes=CHECK,DQQ

--

********************
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. 
********************
Failed Tests (1):
  LLVM :: Instrumentation/NumericalStabilitySanitizer/basic.ll


Testing Time: 73.15s

Total Discovered Tests: 60233
  Skipped          :    33 (0.05%)
  Unsupported      : 16416 (27.25%)
  Passed           : 43717 (72.58%)
  Expectedly Failed:    66 (0.11%)
  Failed           :     1 (0.00%)
[1411/1414] Building CXX object tools/clang/unittests/Tooling/CMakeFiles/ToolingTests.dir/SourceCodeTest.cpp.o
clang++: warning: optimization flag '-ffat-lto-objects' is not supported [-Wignored-optimization-argument]
[1412/1414] Linking CXX executable tools/clang/unittests/Tooling/ToolingTests
FAILED: test/CMakeFiles/check-llvm /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/test/CMakeFiles/check-llvm 
cd /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/test && /usr/bin/python3.10 /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/./bin/llvm-lit -sv /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt/test
ninja: build stopped: subcommand failed.
['ninja', '-C', '/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-pdinhvtt', 'check-llvm', 'check-clang', 'check-lld'] exited with return code 1.
program finished with exit code 0
elapsedTime=996.481886

@llvm-ci
Copy link
Collaborator

llvm-ci commented Jun 29, 2024

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux running on sanitizer-buildbot2 while building llvm at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/66/builds/744

Here is the relevant piece of the build log for the reference:

Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_default/lib/clang/19/lib/i386-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_default/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m32', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_default/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_default/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_default/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_default/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-Wthread-safety', '-Wthread-safety-reference', '-Wthread-safety-beta', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_default/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_default/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_default/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_default/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_default/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_default/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_default/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_default/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 9980 tests, 80 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 
FAIL: libFuzzer-i386-default-Linux :: fuzzer-finalstats.test (9168 of 9980)
******************** TEST 'libFuzzer-i386-default-Linux :: fuzzer-finalstats.test' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /b/sanitizer-x86_64-linux/build/build_default/./bin/clang    -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/fuzzer -m32 /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/SimpleTest.cpp -o /b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/I386DefaultLinuxConfig/Output/fuzzer-finalstats.test.tmp-SimpleTest
+ /b/sanitizer-x86_64-linux/build/build_default/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/fuzzer -m32 /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/SimpleTest.cpp -o /b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/I386DefaultLinuxConfig/Output/fuzzer-finalstats.test.tmp-SimpleTest
RUN: at line 2: /b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/I386DefaultLinuxConfig/Output/fuzzer-finalstats.test.tmp-SimpleTest -seed=1 -runs=77 -print_final_stats=1 2>&1 | FileCheck /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/fuzzer-finalstats.test --check-prefix=FINAL_STATS
+ FileCheck /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/fuzzer-finalstats.test --check-prefix=FINAL_STATS
+ /b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/I386DefaultLinuxConfig/Output/fuzzer-finalstats.test.tmp-SimpleTest -seed=1 -runs=77 -print_final_stats=1
RUN: at line 9: /b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/I386DefaultLinuxConfig/Output/fuzzer-finalstats.test.tmp-SimpleTest /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/dict1.txt -runs=33 -print_final_stats=1 2>&1 | FileCheck /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/fuzzer-finalstats.test --check-prefix=FINAL_STATS1
+ /b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/I386DefaultLinuxConfig/Output/fuzzer-finalstats.test.tmp-SimpleTest /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/dict1.txt -runs=33 -print_final_stats=1
+ FileCheck /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/fuzzer-finalstats.test --check-prefix=FINAL_STATS1
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/fuzzer-finalstats.test:10:15: error: FINAL_STATS1: expected string not found in input
FINAL_STATS1: stat::number_of_executed_units: 33
              ^
<stdin>:1:1: note: scanning from here
INFO: Running with entropic power schedule (0xFF, 100).
^
<stdin>:12:1: note: possible intended match here
stat::number_of_executed_units: 34
^

Input file: <stdin>
Check file: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/fuzzer-finalstats.test

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: INFO: Running with entropic power schedule (0xFF, 100). 
check:10'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
            2: INFO: Seed: 2097931069 
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~
            3: INFO: Loaded 1 modules (9 inline 8-bit counters): 9 [0x56779d2c, 0x56779d35),  
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            4: INFO: Loaded 1 PC tables (9 PCs): 9 [0x56779d38,0x56779d80),  
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Step 16 (test compiler-rt default) failure: test compiler-rt default (failure)
...
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_default/lib/clang/19/lib/i386-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_default/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m32', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_default/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_default/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_default/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_default/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-Wthread-safety', '-Wthread-safety-reference', '-Wthread-safety-beta', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_default/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_default/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_default/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_default/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_default/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_default/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/lit.common.cfg.py:60: warning: Path reported by clang does not exist: "/b/sanitizer-x86_64-linux/build/build_default/lib/clang/19/lib/x86_64-unknown-linux-gnu". This path was found by running ['/b/sanitizer-x86_64-linux/build/build_default/./bin/clang', '--target=x86_64-unknown-linux-gnu', '-m64', '-print-runtime-dir'].
llvm-lit: /b/sanitizer-x86_64-linux/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 9980 tests, 80 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 
FAIL: libFuzzer-i386-default-Linux :: fuzzer-finalstats.test (9168 of 9980)
******************** TEST 'libFuzzer-i386-default-Linux :: fuzzer-finalstats.test' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /b/sanitizer-x86_64-linux/build/build_default/./bin/clang    -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/fuzzer -m32 /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/SimpleTest.cpp -o /b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/I386DefaultLinuxConfig/Output/fuzzer-finalstats.test.tmp-SimpleTest
+ /b/sanitizer-x86_64-linux/build/build_default/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/lib/fuzzer -m32 /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/SimpleTest.cpp -o /b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/I386DefaultLinuxConfig/Output/fuzzer-finalstats.test.tmp-SimpleTest
RUN: at line 2: /b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/I386DefaultLinuxConfig/Output/fuzzer-finalstats.test.tmp-SimpleTest -seed=1 -runs=77 -print_final_stats=1 2>&1 | FileCheck /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/fuzzer-finalstats.test --check-prefix=FINAL_STATS
+ FileCheck /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/fuzzer-finalstats.test --check-prefix=FINAL_STATS
+ /b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/I386DefaultLinuxConfig/Output/fuzzer-finalstats.test.tmp-SimpleTest -seed=1 -runs=77 -print_final_stats=1
RUN: at line 9: /b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/I386DefaultLinuxConfig/Output/fuzzer-finalstats.test.tmp-SimpleTest /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/dict1.txt -runs=33 -print_final_stats=1 2>&1 | FileCheck /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/fuzzer-finalstats.test --check-prefix=FINAL_STATS1
+ /b/sanitizer-x86_64-linux/build/build_default/runtimes/runtimes-bins/compiler-rt/test/fuzzer/I386DefaultLinuxConfig/Output/fuzzer-finalstats.test.tmp-SimpleTest /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/dict1.txt -runs=33 -print_final_stats=1
+ FileCheck /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/fuzzer-finalstats.test --check-prefix=FINAL_STATS1
/b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/fuzzer-finalstats.test:10:15: error: FINAL_STATS1: expected string not found in input
FINAL_STATS1: stat::number_of_executed_units: 33
              ^
<stdin>:1:1: note: scanning from here
INFO: Running with entropic power schedule (0xFF, 100).
^
<stdin>:12:1: note: possible intended match here
stat::number_of_executed_units: 34
^

Input file: <stdin>
Check file: /b/sanitizer-x86_64-linux/build/llvm-project/compiler-rt/test/fuzzer/fuzzer-finalstats.test

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: INFO: Running with entropic power schedule (0xFF, 100). 
check:10'0     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
            2: INFO: Seed: 2097931069 
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~
            3: INFO: Loaded 1 modules (9 inline 8-bit counters): 9 [0x56779d2c, 0x56779d35),  
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            4: INFO: Loaded 1 PC tables (9 PCs): 9 [0x56779d38,0x56779d80),  
check:10'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@alexander-shaposhnikov
Copy link
Collaborator Author

Reverted for now, will look into the build bot breakage.

alexander-shaposhnikov added a commit that referenced this pull request Jun 29, 2024
This reverts commit 493c384
and includes a fix for the build breakage.
lravenclaw pushed a commit to lravenclaw/llvm-project that referenced this pull request Jul 3, 2024
This PR introduces the numerical sanitizer originally proposed by
Clement Courbet on https://reviews.llvm.org/D97854
(https://arxiv.org/abs/2102.12782).

The main additions include:
- Migration to LLVM opaque pointers
- Migration to various updated APIs
- Extended coverage for LLVM instructions/intrinsics
- Code refactoring

The tool is still very experimental, the coverage (e.g. for intrinsics /
library functions) is incomplete.

Link: https://discourse.llvm.org/t/rfc-revival-of-numerical-sanitizer/79601

---------

Co-authored-by: Fangrui Song <i@maskray.me>
lravenclaw pushed a commit to lravenclaw/llvm-project that referenced this pull request Jul 3, 2024
lravenclaw pushed a commit to lravenclaw/llvm-project that referenced this pull request Jul 3, 2024
This reverts commit 493c384
and includes a fix for the build breakage.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category compiler-rt:sanitizer compiler-rt llvm:ir llvm:transforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants