Skip to content

Commit 3402a1a

Browse files
[Clang] Enable nsan instrumentation pass (llvm#97359)
Enable nsan instrumentation pass
1 parent 35668e2 commit 3402a1a

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
#include "llvm/Transforms/Instrumentation/LowerAllowCheckPass.h"
7777
#include "llvm/Transforms/Instrumentation/MemProfiler.h"
7878
#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
79+
#include "llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h"
7980
#include "llvm/Transforms/Instrumentation/PGOInstrumentation.h"
8081
#include "llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h"
8182
#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
@@ -707,6 +708,9 @@ static void addSanitizers(const Triple &TargetTriple,
707708
MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
708709
}
709710

711+
if (LangOpts.Sanitize.has(SanitizerKind::NumericalStability))
712+
MPM.addPass(NumericalStabilitySanitizerPass());
713+
710714
auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
711715
if (LangOpts.Sanitize.has(Mask)) {
712716
bool UseGlobalGC = asanUseGlobalsGC(TargetTriple, CodeGenOpts);

clang/test/CodeGen/no-skipped-passes-O0-opt-bisect.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// RUN: %clang_cc1 -triple x86_64-linux-gnu -O0 %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=local-bounds 2>&1 | FileCheck %s
1010
// RUN: %clang_cc1 -triple x86_64-linux-gnu -O0 %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=dataflow 2>&1 | FileCheck %s
1111
// RUN: %clang_cc1 -triple x86_64-linux-gnu -O0 %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize-coverage-trace-pc-guard 2>&1 | FileCheck %s
12+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -O0 %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=numerical 2>&1 | FileCheck %s
1213
// RUN: %clang_cc1 -triple x86_64-linux-gnu -O0 %s -fdebug-pass-manager -emit-llvm -o /dev/null -fmemory-profile 2>&1 | FileCheck %s
1314

1415
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -opt-bisect-limit=0 %s -fdebug-pass-manager -emit-llvm -o /dev/null 2>&1 | FileCheck %s

clang/test/CodeGen/nsan-basic.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %clang_cc1 -triple x86_64 -emit-llvm -o - -fsanitize=numerical %s | FileCheck %s
2+
3+
// CHECK: Function Attrs: noinline nounwind optnone sanitize_numerical_stability
4+
float add(float x, float y) {
5+
float z = x + y;
6+
return z;
7+
}

clang/test/CodeGen/sanitizer-module-constructor.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=address -O3 -emit-llvm -fdebug-pass-manager -o - %s 2>&1 | FileCheck %s
22
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=thread -O3 -emit-llvm -fdebug-pass-manager -o - %s 2>&1 | FileCheck %s
33
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=memory -O3 -emit-llvm -fdebug-pass-manager -o - %s 2>&1 | FileCheck %s
4+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=numerical -O3 -emit-llvm -fdebug-pass-manager -o - %s 2>&1 | FileCheck %s
45

56
// This is regression test for PR42877
67

0 commit comments

Comments
 (0)