Skip to content

Commit 6e09818

Browse files
committed
[DFSan][NewPM] Handle dfsan under NPM
Make it required. Since it's a module pass, optnone won't test it, so extend the clang test to also use opt-bisect now that it's supported. 14/16 check-dfsan tests failed with NPM enabled, now all pass. Reviewed By: leonardchan Differential Revision: https://reviews.llvm.org/D91385
1 parent 9a85643 commit 6e09818

File tree

4 files changed

+35
-14
lines changed

4 files changed

+35
-14
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#include "llvm/Transforms/Instrumentation.h"
6666
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
6767
#include "llvm/Transforms/Instrumentation/BoundsChecking.h"
68+
#include "llvm/Transforms/Instrumentation/DataFlowSanitizer.h"
6869
#include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
6970
#include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
7071
#include "llvm/Transforms/Instrumentation/InstrProfiling.h"
@@ -1295,6 +1296,14 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
12951296
HWASanPass(SanitizerKind::HWAddress, false);
12961297
HWASanPass(SanitizerKind::KernelHWAddress, true);
12971298

1299+
if (LangOpts.Sanitize.has(SanitizerKind::DataFlow)) {
1300+
PB.registerOptimizerLastEPCallback(
1301+
[this](ModulePassManager &MPM, PassBuilder::OptimizationLevel Level) {
1302+
MPM.addPass(
1303+
DataFlowSanitizerPass(LangOpts.SanitizerBlacklistFiles));
1304+
});
1305+
}
1306+
12981307
if (Optional<GCOVOptions> Options = getGCOVOptions(CodeGenOpts, LangOpts))
12991308
PB.registerPipelineStartEPCallback(
13001309
[Options](ModulePassManager &MPM,

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

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Test that no passes are skipped under NPM with -O0/opt-bisect
2+
//
3+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -enable-npm-optnone -O0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null 2>&1 | FileCheck %s
4+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -enable-npm-optnone -O0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null -fcoroutines-ts 2>&1 | FileCheck %s
5+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -enable-npm-optnone -O0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=address 2>&1 | FileCheck %s
6+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -enable-npm-optnone -O0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=hwaddress 2>&1 | FileCheck %s
7+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -enable-npm-optnone -O0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=memory 2>&1 | FileCheck %s
8+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -enable-npm-optnone -O0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=thread 2>&1 | FileCheck %s
9+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -enable-npm-optnone -O0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=local-bounds 2>&1 | FileCheck %s
10+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -enable-npm-optnone -O0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=dataflow 2>&1 | FileCheck %s
11+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -enable-npm-optnone -O0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize-coverage-trace-pc-guard 2>&1 | FileCheck %s
12+
13+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -opt-bisect-limit=0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null 2>&1 | FileCheck %s
14+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -opt-bisect-limit=0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null -fcoroutines-ts 2>&1 | FileCheck %s
15+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -opt-bisect-limit=0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=address 2>&1 | FileCheck %s
16+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -opt-bisect-limit=0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=hwaddress 2>&1 | FileCheck %s
17+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -opt-bisect-limit=0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=memory 2>&1 | FileCheck %s
18+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -opt-bisect-limit=0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=thread 2>&1 | FileCheck %s
19+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -opt-bisect-limit=0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=local-bounds 2>&1 | FileCheck %s
20+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -opt-bisect-limit=0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize=dataflow 2>&1 | FileCheck %s
21+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -mllvm -opt-bisect-limit=0 -fexperimental-new-pass-manager %s -fdebug-pass-manager -emit-llvm -o /dev/null -fsanitize-coverage-trace-pc-guard 2>&1 | FileCheck %s
22+
23+
// CHECK-NOT: Skipping pass
24+
25+
int func(int a) { return a; }

llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class DataFlowSanitizerPass : public PassInfoMixin<DataFlowSanitizerPass> {
2424
const std::vector<std::string> &ABIListFiles = std::vector<std::string>())
2525
: ABIListFiles(ABIListFiles) {}
2626
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
27+
static bool isRequired() { return true; }
2728
};
2829

2930
} // namespace llvm

0 commit comments

Comments
 (0)