From f4076dc9958421b4989a43994b6d26906ab58d08 Mon Sep 17 00:00:00 2001 From: Timur Iskhodzhanov Date: Fri, 26 Dec 2014 17:00:51 +0000 Subject: [PATCH] Band-aid fix for PR22032: don't emit DWARF debug info if AddressSanitizer is enabled on Windows git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224860 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 19 ++++++++++++++++--- test/DebugInfo/COFF/asan-module-ctor.ll | 3 +++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 80221d7feb6..97ef12c8328 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -222,12 +222,25 @@ bool AsmPrinter::doInitialization(Module &M) { } if (MAI->doesSupportDebugInformation()) { - if (Triple(TM.getTargetTriple()).isKnownWindowsMSVCEnvironment()) + bool skip_dwarf = false; + if (Triple(TM.getTargetTriple()).isKnownWindowsMSVCEnvironment()) { Handlers.push_back(HandlerInfo(new WinCodeViewLineTables(this), DbgTimerName, CodeViewLineTablesGroupName)); - DD = new DwarfDebug(this, &M); - Handlers.push_back(HandlerInfo(DD, DbgTimerName, DWARFGroupName)); + // FIXME: Don't emit DWARF debug info if there's at least one function + // with AddressSanitizer instrumentation. + // This is a band-aid fix for PR22032. + for (auto &F : M.functions()) { + if (F.hasFnAttribute(Attribute::SanitizeAddress)) { + skip_dwarf = true; + break; + } + } + } + if (!skip_dwarf) { + DD = new DwarfDebug(this, &M); + Handlers.push_back(HandlerInfo(DD, DbgTimerName, DWARFGroupName)); + } } EHStreamer *ES = nullptr; diff --git a/test/DebugInfo/COFF/asan-module-ctor.ll b/test/DebugInfo/COFF/asan-module-ctor.ll index 039a55d44ad..02c2a5810dd 100644 --- a/test/DebugInfo/COFF/asan-module-ctor.ll +++ b/test/DebugInfo/COFF/asan-module-ctor.ll @@ -13,6 +13,9 @@ ; X86-NEXT: calll ___asan_init_v3 ; X86-NEXT: retl +; Make sure we don't put any DWARF debug info for ASan-instrumented modules. +; X86-NOT: DWARF + ; ModuleID = 'asan.c' target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32" target triple = "i686-pc-win32"