[clang] e9802aa - Revert "Run Coverage pass before other *San passes under new pass manager"

Leonard Chan via cfe-commits cfe-commits at lists.llvm.org
Thu May 14 15:22:35 PDT 2020


Author: Leonard Chan
Date: 2020-05-14T15:19:27-07:00
New Revision: e9802aa4221ba3857041c2328639ce2aac0ace67

URL: https://github.com/llvm/llvm-project/commit/e9802aa4221ba3857041c2328639ce2aac0ace67
DIFF: https://github.com/llvm/llvm-project/commit/e9802aa4221ba3857041c2328639ce2aac0ace67.diff

LOG: Revert "Run Coverage pass before other *San passes under new pass manager"

This reverts commit 7d5bb94d78386e4653535c35d3e8258bf4502340.

Reverting since this leads to a linker error we're seeing on Fuchsia.
The underlying issue seems to be that inlining is run after sanitizers
and causes different comdat groups instrumented by Sancov to reference
non-key symbols defined in other comdat groups.

Will re-land this patch after a fix for that is landed.

Added: 
    

Modified: 
    clang/lib/CodeGen/BackendUtil.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 7b876df852b5..33627f3a6733 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1001,15 +1001,6 @@ static void addSanitizersAtO0(ModulePassManager &MPM,
                               const Triple &TargetTriple,
                               const LangOptions &LangOpts,
                               const CodeGenOptions &CodeGenOpts) {
-  if (CodeGenOpts.SanitizeCoverageType ||
-      CodeGenOpts.SanitizeCoverageIndirectCalls ||
-      CodeGenOpts.SanitizeCoverageTraceCmp) {
-    auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-    MPM.addPass(ModuleSanitizerCoveragePass(
-        SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
-        CodeGenOpts.SanitizeCoverageBlacklistFiles));
-  }
-
   auto ASanPass = [&](SanitizerMask Mask, bool CompileKernel) {
     MPM.addPass(RequireAnalysisPass<ASanGlobalsMetadataAnalysis, Module>());
     bool Recover = CodeGenOpts.SanitizeRecover.has(Mask);
@@ -1250,17 +1241,6 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
             EntryExitInstrumenterPass(/*PostInlining=*/false)));
       });
 
-      if (CodeGenOpts.SanitizeCoverageType ||
-          CodeGenOpts.SanitizeCoverageIndirectCalls ||
-          CodeGenOpts.SanitizeCoverageTraceCmp) {
-        PB.registerPipelineStartEPCallback([&](ModulePassManager &MPM) {
-          auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
-          MPM.addPass(ModuleSanitizerCoveragePass(
-              SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
-              CodeGenOpts.SanitizeCoverageBlacklistFiles));
-        });
-      }
-
       // Register callbacks to schedule sanitizer passes at the appropriate part of
       // the pipeline.
       // FIXME: either handle asan/the remaining sanitizers or error out
@@ -1345,6 +1325,15 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
       }
     }
 
+    if (CodeGenOpts.SanitizeCoverageType ||
+        CodeGenOpts.SanitizeCoverageIndirectCalls ||
+        CodeGenOpts.SanitizeCoverageTraceCmp) {
+      auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+      MPM.addPass(ModuleSanitizerCoveragePass(
+          SancovOpts, CodeGenOpts.SanitizeCoverageWhitelistFiles,
+          CodeGenOpts.SanitizeCoverageBlacklistFiles));
+    }
+
     if (LangOpts.Sanitize.has(SanitizerKind::HWAddress)) {
       bool Recover = CodeGenOpts.SanitizeRecover.has(SanitizerKind::HWAddress);
       MPM.addPass(HWAddressSanitizerPass(


        


More information about the cfe-commits mailing list