<br><br><div class="gmail_quote"><div dir="ltr">On Fri., 18 Aug. 2017, 6:16 pm Adrian Prantl via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Fri Aug 18 18:15:06 2017<br>
New Revision: 311217<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=311217&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=311217&view=rev</a><br>
Log:<br>
Filter out non-constant DIGlobalVariableExpressions reachable via the CU<br>
<br>
They won't affect the DWARF output, but they will mess with the<br>
sorting of the fragments. This fixes the crash reported in PR34159.<br>
<br>
<a href="https://bugs.llvm.org/show_bug.cgi?id=34159" rel="noreferrer" target="_blank">https://bugs.llvm.org/show_bug.cgi?id=34159</a><br>
<br>
Modified:<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
llvm/trunk/test/DebugInfo/X86/split-global.ll<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=311217&r1=311216&r2=311217&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=311217&r1=311216&r2=311217&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Aug 18 18:15:06 2017<br>
@@ -592,8 +592,15 @@ void DwarfDebug::beginModule() {<br>
DwarfCompileUnit &CU = getOrCreateDwarfCompileUnit(CUNode);<br>
<br>
// Global Variables.<br>
- for (auto *GVE : CUNode->getGlobalVariables())<br>
- GVMap[GVE->getVariable()].push_back({nullptr, GVE->getExpression()});<br>
+ for (auto *GVE : CUNode->getGlobalVariables()) {<br>
+ // Don't bother adding DIGlobalVariableExpressions listed in the CU if we<br>
+ // already know about the variable and it isn't adding a constant<br>
+ // expression.<br>
+ auto &GVMapEntry = GVMap[GVE->getVariable()];<br>
+ auto *Expr = GVE->getExpression();<br>
+ if (!GVMapEntry.size() || (Expr && Expr->isConstant()))<br>
+ GVMapEntry.push_back({nullptr, Expr});<br>
+ }<br>
DenseSet<DIGlobalVariable *> Processed;<br>
for (auto *GVE : CUNode->getGlobalVariables()) {<br>
DIGlobalVariable *GV = GVE->getVariable();<br>
<br>
Modified: llvm/trunk/test/DebugInfo/X86/split-global.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/split-global.ll?rev=311217&r1=311216&r2=311217&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/split-global.ll?rev=311217&r1=311216&r2=311217&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/split-global.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/split-global.ll Fri Aug 18 18:15:06 2017<br>
@@ -39,7 +39,7 @@ target triple = "x86_64-apple-macosx10.1<br>
!1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4)<br>
!2 = !DIFile(filename: "g.c", directory: "/")<br>
!3 = !{}<br>
-!4 = !{!12, !13, !14, !15, !17, !18}<br>
+!4 = !{!12, !13, !14, !15, !17, !18, !20}<br>
!5 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !2, line: 1, size: 64, elements: !6)<br>
!6 = !{!7, !9}<br>
!7 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !5, file: !2, line: 1, baseType: !8, size: 32)<br>
@@ -58,3 +58,4 @@ target triple = "x86_64-apple-macosx10.1<br>
!18 = !DIGlobalVariableExpression(var: !19, expr: !DIExpression(DW_OP_constu, 2,<br>
DW_OP_stack_value, DW_OP_LLVM_fragment, 32, 32))<br>
!19 = distinct !DIGlobalVariable(name: "full_const", scope: !1, file: !2, line: 1, type: !5, isLocal: false, isDefinition: true)<br>
+!20 = !DIGlobalVariableExpression(var: !0)<br></blockquote></div><div><br></div><div>Should this be/is this valid ir?</div><div><br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<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>