summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/BackendUtil.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2019-07-17 21:45:19 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2019-07-17 21:45:19 +0000
commit3b82b92c6b90691064c7531ecc03366cf7526d8a (patch)
tree01de6444e53b0dbbe70b79935582ce7898cabe96 /clang/lib/CodeGen/BackendUtil.cpp
parentbe4be6120f10f557d32de5e33ff8233e17fe61de (diff)
downloadbcm5719-llvm-3b82b92c6b90691064c7531ecc03366cf7526d8a.tar.gz
bcm5719-llvm-3b82b92c6b90691064c7531ecc03366cf7526d8a.zip
hwasan: Initialize the pass only once.
This will let us instrument globals during initialization. This required making the new PM pass a module pass, which should still provide access to analyses via the ModuleAnalysisManager. Differential Revision: https://reviews.llvm.org/D64843 llvm-svn: 366379
Diffstat (limited to 'clang/lib/CodeGen/BackendUtil.cpp')
-rw-r--r--clang/lib/CodeGen/BackendUtil.cpp38
1 files changed, 10 insertions, 28 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 40a529c319f..497652e85b4 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -967,17 +967,6 @@ static void addSanitizersAtO0(ModulePassManager &MPM,
if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
}
-
- if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) {
- bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
- MPM.addPass(createModuleToFunctionPassAdaptor(
- HWAddressSanitizerPass(/*CompileKernel=*/false, Recover)));
- }
-
- if (LangOpts.Sanitize.has(SanitizerKind::KernelHWAddress)) {
- MPM.addPass(createModuleToFunctionPassAdaptor(
- HWAddressSanitizerPass(/*CompileKernel=*/true, /*Recover=*/true)));
- }
}
/// A clean version of `EmitAssembly` that uses the new pass manager.
@@ -1176,23 +1165,6 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
UseOdrIndicator));
});
}
- if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) {
- bool Recover =
- CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
- PB.registerOptimizerLastEPCallback(
- [Recover](FunctionPassManager &FPM,
- PassBuilder::OptimizationLevel Level) {
- FPM.addPass(HWAddressSanitizerPass(
- /*CompileKernel=*/false, Recover));
- });
- }
- if (LangOpts.Sanitize.has(SanitizerKind::KernelHWAddress)) {
- PB.registerOptimizerLastEPCallback(
- [](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) {
- FPM.addPass(HWAddressSanitizerPass(
- /*CompileKernel=*/true, /*Recover=*/true));
- });
- }
if (Optional<GCOVOptions> Options = getGCOVOptions(CodeGenOpts))
PB.registerPipelineStartEPCallback([Options](ModulePassManager &MPM) {
MPM.addPass(GCOVProfilerPass(*Options));
@@ -1219,6 +1191,16 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
}
}
+ if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) {
+ bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
+ MPM.addPass(HWAddressSanitizerPass(
+ /*CompileKernel=*/false, Recover));
+ }
+ if (LangOpts.Sanitize.has(SanitizerKind::KernelHWAddress)) {
+ MPM.addPass(HWAddressSanitizerPass(
+ /*CompileKernel=*/true, /*Recover=*/true));
+ }
+
if (CodeGenOpts.OptimizationLevel == 0)
addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
}
OpenPOWER on IntegriCloud