summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2019-05-09 06:09:35 +0000
committerPetr Hosek <phosek@chromium.org>2019-05-09 06:09:35 +0000
commit366cda03a89c7a03fa0c83003ba4bca42d284230 (patch)
tree6400c832f000d3a7f3517351d1bb4a72157dd3dc
parent36851a66c8c98f005e4e9a65fc1bd8e267fa1d11 (diff)
downloadbcm5719-llvm-366cda03a89c7a03fa0c83003ba4bca42d284230.tar.gz
bcm5719-llvm-366cda03a89c7a03fa0c83003ba4bca42d284230.zip
[NewPM] Setup Passes for KASan and KMSan
While ASan and MSan passes were already ported to new PM, the kernel variants weren't setup in the pipeline which makes the KASan and KMSan tests in Clang fail. Differential Revision: https://reviews.llvm.org/D61664 llvm-svn: 360313
-rw-r--r--clang/lib/CodeGen/BackendUtil.cpp28
-rw-r--r--llvm/lib/Passes/PassRegistry.def5
2 files changed, 24 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index cd2a5f6fa3f..f6018e7d62d 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -931,22 +931,34 @@ static void addSanitizersAtO0(ModulePassManager &MPM,
const Triple &TargetTriple,
const LangOptions &LangOpts,
const CodeGenOptions &CodeGenOpts) {
- if (LangOpts.Sanitize.has(SanitizerKind::Address)) {
+ auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
MPM.addPass(RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
- bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Address);
- MPM.addPass(createModuleToFunctionPassAdaptor(
- AddressSanitizerPass(/*CompileKernel=*/false, Recover,
- CodeGenOpts.SanitizeAddressUseAfterScope)));
+ bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
+ MPM.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
+ CompileKernel, Recover, CodeGenOpts.SanitizeAddressUseAfterScope)));
bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts);
- MPM.addPass(ModuleAddressSanitizerPass(
- /*CompileKernel=*/false, Recover, ModuleUseAfterScope,
- CodeGenOpts.SanitizeAddressUseOdrIndicator));
+ MPM.addPass(
+ ModuleAddressSanitizerPass(CompileKernel, Recover, ModuleUseAfterScope,
+ CodeGenOpts.SanitizeAddressUseOdrIndicator));
+ };
+
+ if (LangOpts.Sanitize.has(SanitizerKind::Address)) {
+ ASanPass(SanitizerKind::Address, /*CompileKernel=*/false);
+ }
+
+ if (LangOpts.Sanitize.has(SanitizerKind::KernelAddress)) {
+ ASanPass(SanitizerKind::KernelAddress, /*CompileKernel=*/true);
}
if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass({})));
}
+ if (LangOpts.Sanitize.has(SanitizerKind::KernelMemory)) {
+ MPM.addPass(createModuleToFunctionPassAdaptor(
+ MemorySanitizerPass({0, false, /*Kernel=*/true})));
+ }
+
if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
}
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index 9ec9080bf55..68f7d45cc43 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -83,7 +83,8 @@ MODULE_PASS("strip-dead-prototypes", StripDeadPrototypesPass())
MODULE_PASS("synthetic-counts-propagation", SyntheticCountsPropagation())
MODULE_PASS("wholeprogramdevirt", WholeProgramDevirtPass(nullptr, nullptr))
MODULE_PASS("verify", VerifierPass())
-MODULE_PASS("asan-module", ModuleAddressSanitizerPass(false, false, true, false))
+MODULE_PASS("asan-module", ModuleAddressSanitizerPass(/*CompileKernel=*/false, false, true, false))
+MODULE_PASS("kasan-module", ModuleAddressSanitizerPass(/*CompileKernel=*/true, false, true, false))
#undef MODULE_PASS
#ifndef CGSCC_ANALYSIS
@@ -235,7 +236,9 @@ FUNCTION_PASS("view-cfg", CFGViewerPass())
FUNCTION_PASS("view-cfg-only", CFGOnlyViewerPass())
FUNCTION_PASS("transform-warning", WarnMissedTransformationsPass())
FUNCTION_PASS("asan", AddressSanitizerPass(false, false, false))
+FUNCTION_PASS("kasan", AddressSanitizerPass(true, false, false))
FUNCTION_PASS("msan", MemorySanitizerPass({}))
+FUNCTION_PASS("kmsan", MemorySanitizerPass({0, false, /*Kernel=*/true}))
FUNCTION_PASS("tsan", ThreadSanitizerPass())
#undef FUNCTION_PASS
OpenPOWER on IntegriCloud