[llvm] r302923 - [codeview] Fix assertion failure introduced in r295354 refactoring

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri May 12 10:02:41 PDT 2017


Author: rnk
Date: Fri May 12 12:02:40 2017
New Revision: 302923

URL: http://llvm.org/viewvc/llvm-project?rev=302923&view=rev
Log:
[codeview] Fix assertion failure introduced in r295354 refactoring

CodeViewDebug sets Asm to nullptr to disable debug info generation.  You
can get a .ll file like no-cus.ll from 'clang -gcodeview -g0', which
happens in the ubsan test suite.

Added:
    llvm/trunk/test/DebugInfo/COFF/no-cus.ll
Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp?rev=302923&r1=302922&r2=302923&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp Fri May 12 12:02:40 2017
@@ -129,10 +129,9 @@ bool hasDebugInfo(const MachineModuleInf
 }
 
 void DebugHandlerBase::beginFunction(const MachineFunction *MF) {
-  assert(Asm);
   PrevInstBB = nullptr;
 
-  if (!hasDebugInfo(MMI, MF)) {
+  if (!Asm || !hasDebugInfo(MMI, MF)) {
     skippedNonDebugFunction();
     return;
   }

Added: llvm/trunk/test/DebugInfo/COFF/no-cus.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/no-cus.ll?rev=302923&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/no-cus.ll (added)
+++ llvm/trunk/test/DebugInfo/COFF/no-cus.ll Fri May 12 12:02:40 2017
@@ -0,0 +1,25 @@
+; RUN: llc < %s -filetype=obj -o %t.o
+; RUN: llvm-objdump -section-headers %t.o | FileCheck %s
+
+; Don't emit debug info in this scenario and don't crash.
+
+; CHECK-NOT: .debug$S
+; CHECK: .text
+; CHECK-NOT: .debug$S
+
+; ModuleID = 't.cpp'
+source_filename = "t.cpp"
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc19.10.24728"
+
+define void @f() {
+entry:
+  ret void
+}
+
+!llvm.module.flags = !{!0, !1}
+!llvm.ident = !{!2}
+
+!0 = !{i32 2, !"CodeView", i32 1}
+!1 = !{i32 1, !"PIC Level", i32 2}
+!2 = !{!"clang version 5.0.0 "}




More information about the llvm-commits mailing list