summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorLeonard Chan <leonardchan@google.com>2018-10-17 15:38:22 +0000
committerLeonard Chan <leonardchan@google.com>2018-10-17 15:38:22 +0000
commitebd10a24f4c3bc24011b399d93fca789fcac8986 (patch)
tree84591495c9545dae28504e4e5fdf26f8d0a9c24b /clang/lib
parent4821937d2ef9120673ecdd6d139ceddf29a54957 (diff)
downloadbcm5719-llvm-ebd10a24f4c3bc24011b399d93fca789fcac8986.tar.gz
bcm5719-llvm-ebd10a24f4c3bc24011b399d93fca789fcac8986.zip
[PassManager/Sanitizer] Enable usage of ported AddressSanitizer passes with -fsanitize=address
Enable usage of `AddressSanitizer` and `AddressModuleSanitizer` ported from the legacy to the new PassManager. This patch depends on https://reviews.llvm.org/D52739. Differential Revision: https://reviews.llvm.org/D52814 llvm-svn: 344699
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/BackendUtil.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index fd9a95b7199..ee9fa844519 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -52,6 +52,7 @@
#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
#include "llvm/Transforms/InstCombine/InstCombine.h"
#include "llvm/Transforms/Instrumentation.h"
+#include "llvm/Transforms/Instrumentation/AddressSanitizerPass.h"
#include "llvm/Transforms/Instrumentation/BoundsChecking.h"
#include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
#include "llvm/Transforms/ObjCARC.h"
@@ -1022,6 +1023,16 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
CodeGenOpts.DebugPassManager);
}
}
+
+ if (LangOpts.Sanitize.has(SanitizerKind::Address)) {
+ bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::Address);
+ MPM.addPass(createModuleToFunctionPassAdaptor(
+ AddressSanitizerPass(/*CompileKernel=*/false, Recover,
+ CodeGenOpts.SanitizeAddressUseAfterScope)));
+ bool ModuleUseAfterScope = asanUseGlobalsGC(TargetTriple, CodeGenOpts);
+ MPM.addPass(AddressSanitizerPass(/*CompileKernel=*/false, Recover,
+ ModuleUseAfterScope));
+ }
}
// FIXME: We still use the legacy pass manager to do code generation. We
OpenPOWER on IntegriCloud