diff options
author | Philip Pfaffe <philip.pfaffe@gmail.com> | 2019-01-17 10:10:47 +0000 |
---|---|---|
committer | Philip Pfaffe <philip.pfaffe@gmail.com> | 2019-01-17 10:10:47 +0000 |
commit | 88a13b91591747ca1b399f8937c022f710360837 (patch) | |
tree | e84e631db7b4fb0825d6aadcf344638b51a97866 /clang/lib/CodeGen/BackendUtil.cpp | |
parent | 07f1c62371c57a66b23933811a585e201dde8e27 (diff) | |
download | bcm5719-llvm-88a13b91591747ca1b399f8937c022f710360837.tar.gz bcm5719-llvm-88a13b91591747ca1b399f8937c022f710360837.zip |
[NewPM] Add -fsanitize={memory,thread} handling to clang
Summary: This is the missing bit to drive thread and memory sanitizers through clang using the new PassManager.
Reviewers: chandlerc, fedor.sergeev, vitalybuka, leonardchan
Subscribers: bollu, llvm-commits
Differential Revision: https://reviews.llvm.org/D56831
llvm-svn: 351423
Diffstat (limited to 'clang/lib/CodeGen/BackendUtil.cpp')
-rw-r--r-- | clang/lib/CodeGen/BackendUtil.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index b927acabac5..3536bf02939 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1015,11 +1015,22 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager( // Register callbacks to schedule sanitizer passes at the appropriate part of // the pipeline. + // FIXME: either handle asan/the remaining sanitizers or error out if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds)) PB.registerScalarOptimizerLateEPCallback( [](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) { FPM.addPass(BoundsCheckingPass()); }); + if (LangOpts.Sanitize.has(SanitizerKind::Memory)) + PB.registerOptimizerLastEPCallback( + [](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) { + FPM.addPass(MemorySanitizerPass()); + }); + if (LangOpts.Sanitize.has(SanitizerKind::Thread)) + PB.registerOptimizerLastEPCallback( + [](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) { + FPM.addPass(ThreadSanitizerPass()); + }); if (Optional<GCOVOptions> Options = getGCOVOptions(CodeGenOpts)) PB.registerPipelineStartEPCallback([Options](ModulePassManager &MPM) { MPM.addPass(GCOVProfilerPass(*Options)); |