<div dir="ltr">The actual effect of this is that we don't emit any symbol info for functions that lack a subprogram, right? If so, yeah, sounds good, let's merge to 3.9.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 27, 2016 at 10:14 PM, David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I think this should get merged into 3.9, it is apparently blocking the rust folks from using it.<div>Thoughts?</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 28, 2016 at 1:03 AM, David Majnemer via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: majnemer<br>
Date: Thu Jul 28 00:03:22 2016<br>
New Revision: 276956<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=276956&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=276956&view=rev</a><br>
Log:<br>
[CodeView] Don't crash on functions without subprograms<br>
<br>
A function may have instructions annotated with debug info without<br>
having a subprogram.<br>
<br>
This fixes PR28747.<br>
<br>
Added:<br>
llvm/trunk/test/DebugInfo/COFF/pr28747.ll<br>
Modified:<br>
llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp<br>
llvm/trunk/test/DebugInfo/COFF/inlining-same-name.ll<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=276956&r1=276955&r2=276956&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=276956&r1=276955&r2=276956&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Thu Jul 28 00:03:22 2016<br>
@@ -217,10 +217,7 @@ TypeIndex CodeViewDebug::getScopeIndex(c<br>
}<br>
<br>
TypeIndex CodeViewDebug::getFuncIdForSubprogram(const DISubprogram *SP) {<br>
- // It's possible to ask for the FuncId of a function which doesn't have a<br>
- // subprogram: inlining a function with debug info into a function with none.<br>
- if (!SP)<br>
- return TypeIndex::None();<br>
+ assert(SP);<br>
<br>
// Check if we've already translated this subprogram.<br>
auto I = TypeIndices.find({SP, nullptr});<br>
@@ -624,11 +621,12 @@ void CodeViewDebug::emitDebugInfoForFunc<br>
<br>
std::string FuncName;<br>
auto *SP = GV->getSubprogram();<br>
+ assert(SP);<br>
setCurrentSubprogram(SP);<br>
<br>
// If we have a display name, build the fully qualified name by walking the<br>
// chain of scopes.<br>
- if (SP != nullptr && !SP->getDisplayName().empty())<br>
+ if (!SP->getDisplayName().empty())<br>
FuncName =<br>
getFullyQualifiedName(SP->getScope().resolve(), SP->getDisplayName());<br>
<br>
@@ -867,7 +865,7 @@ void CodeViewDebug::collectVariableInfo(<br>
void CodeViewDebug::beginFunction(const MachineFunction *MF) {<br>
assert(!CurFn && "Can't process two functions at once!");<br>
<br>
- if (!Asm || !MMI->hasDebugInfo())<br>
+ if (!Asm || !MMI->hasDebugInfo() || !MF->getFunction()->getSubprogram())<br>
return;<br>
<br>
DebugHandlerBase::beginFunction(MF);<br>
@@ -1942,7 +1940,8 @@ void CodeViewDebug::beginInstruction(con<br>
DebugHandlerBase::beginInstruction(MI);<br>
<br>
// Ignore DBG_VALUE locations and function prologue.<br>
- if (!Asm || MI->isDebugValue() || MI->getFlag(MachineInstr::FrameSetup))<br>
+ if (!Asm || !CurFn || MI->isDebugValue() ||<br>
+ MI->getFlag(MachineInstr::FrameSetup))<br>
return;<br>
DebugLoc DL = MI->getDebugLoc();<br>
if (DL == PrevInstLoc || !DL)<br>
<br>
Modified: llvm/trunk/test/DebugInfo/COFF/inlining-same-name.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/inlining-same-name.ll?rev=276956&r1=276955&r2=276956&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/inlining-same-name.ll?rev=276956&r1=276955&r2=276956&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/COFF/inlining-same-name.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/COFF/inlining-same-name.ll Thu Jul 28 00:03:22 2016<br>
@@ -33,7 +33,7 @@<br>
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"<br>
target triple = "x86_64-pc-windows-msvc"<br>
<br>
-define void @main(i32* %i.i) {<br>
+define void @main(i32* %i.i) !dbg !16 {<br>
store volatile i32 3, i32* %i.i, !dbg !6<br>
store volatile i32 3, i32* %i.i, !dbg !19<br>
ret void<br>
<br>
Added: llvm/trunk/test/DebugInfo/COFF/pr28747.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/pr28747.ll?rev=276956&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/pr28747.ll?rev=276956&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/COFF/pr28747.ll (added)<br>
+++ llvm/trunk/test/DebugInfo/COFF/pr28747.ll Thu Jul 28 00:03:22 2016<br>
@@ -0,0 +1,44 @@<br>
+; RUN: llc < %s | FileCheck %s<br>
+<br>
+; CHECK: .section .debug$S,"dr"{{$}}<br>
+; CHECK-NEXT: .p2align 2<br>
+; CHECK-NEXT: .long 4<br>
+; CHECK-NEXT: .cv_filechecksums<br>
+; CHECK-NEXT: .cv_stringtable<br>
+<br>
+target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"<br>
+target triple = "i686-pc-windows-msvc18.0.0"<br>
+<br>
+define void @baz() {<br>
+entry:<br>
+ %x.i.i = alloca i32, align 4<br>
+ call void @llvm.dbg.declare(metadata i32* %x.i.i, metadata !6, metadata !12), !dbg !13<br>
+ store i32 5, i32* %x.i.i, align 4, !dbg !13<br>
+ ret void<br>
+}<br>
+<br>
+; Function Attrs: nounwind readnone<br>
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #0<br>
+<br>
+attributes #0 = { nounwind readnone }<br>
+<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0}<br>
+!llvm.module.flags = !{!3, !4}<br>
+!llvm.ident = !{!5}<br>
+<br>
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 (trunk 276756) (llvm/trunk 276952)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)<br>
+!1 = !DIFile(filename: "-", directory: "/")<br>
+!2 = !{}<br>
+!3 = !{i32 2, !"CodeView", i32 1}<br>
+!4 = !{i32 2, !"Debug Info Version", i32 3}<br>
+!5 = !{!"clang version 4.0.0 (trunk 276756) (llvm/trunk 276952)"}<br>
+!6 = !DILocalVariable(name: "x", scope: !7, file: !8, line: 1, type: !11)<br>
+!7 = distinct !DISubprogram(name: "foo", scope: !8, file: !8, line: 1, type: !9, isLocal: true, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !0, variables: !2)<br>
+!8 = !DIFile(filename: "<stdin>", directory: "/")<br>
+!9 = !DISubroutineType(types: !10)<br>
+!10 = !{null}<br>
+!11 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)<br>
+!12 = !DIExpression()<br>
+!13 = !DILocation(line: 1, column: 56, scope: !7, inlinedAt: !14)<br>
+!14 = distinct !DILocation(line: 2, column: 52, scope: !15)<br>
+!15 = distinct !DISubprogram(name: "bar", scope: !8, file: !8, line: 2, type: !9, isLocal: true, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, variables: !2)<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>