<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 22, 2017, at 5:51 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div dir="ltr" class="">On Fri., 18 Aug. 2017, 6:16 pm Adrian Prantl via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;">Author: adrian<br class="">Date: Fri Aug 18 18:15:06 2017<br class="">New Revision: 311217<br class=""><br class="">URL:<span class="Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=311217&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=311217&view=rev</a><br class="">Log:<br class="">Filter out non-constant DIGlobalVariableExpressions reachable via the CU<br class=""><br class="">They won't affect the DWARF output, but they will mess with the<br class="">sorting of the fragments. This fixes the crash reported in PR34159.<br class=""><br class=""><a href="https://bugs.llvm.org/show_bug.cgi?id=34159" rel="noreferrer" target="_blank" class="">https://bugs.llvm.org/show_bug.cgi?id=34159</a><br class=""><br class="">Modified:<br class="">   <span class="Apple-converted-space"> </span>llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br class="">   <span class="Apple-converted-space"> </span>llvm/trunk/test/DebugInfo/X86/split-global.ll<br class=""><br class="">Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br class="">URL:<span class="Apple-converted-space"> </span><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" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=311217&r1=311216&r2=311217&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br class="">+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Aug 18 18:15:06 2017<br class="">@@ -592,8 +592,15 @@ void DwarfDebug::beginModule() {<br class="">     DwarfCompileUnit &CU = getOrCreateDwarfCompileUnit(CUNode);<br class=""><br class="">     // Global Variables.<br class="">-    for (auto *GVE : CUNode->getGlobalVariables())<br class="">-      GVMap[GVE->getVariable()].push_back({nullptr, GVE->getExpression()});<br class="">+    for (auto *GVE : CUNode->getGlobalVariables()) {<br class="">+      // Don't bother adding DIGlobalVariableExpressions listed in the CU if we<br class="">+      // already know about the variable and it isn't adding a constant<br class="">+      // expression.<br class="">+      auto &GVMapEntry = GVMap[GVE->getVariable()];<br class="">+      auto *Expr = GVE->getExpression();<br class="">+      if (!GVMapEntry.size() || (Expr && Expr->isConstant()))<br class="">+        GVMapEntry.push_back({nullptr, Expr});<br class="">+    }<br class="">     DenseSet<DIGlobalVariable *> Processed;<br class="">     for (auto *GVE : CUNode->getGlobalVariables()) {<br class="">       DIGlobalVariable *GV = GVE->getVariable();<br class=""><br class="">Modified: llvm/trunk/test/DebugInfo/X86/split-global.ll<br class="">URL:<span class="Apple-converted-space"> </span><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" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/split-global.ll?rev=311217&r1=311216&r2=311217&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/test/DebugInfo/X86/split-global.ll (original)<br class="">+++ llvm/trunk/test/DebugInfo/X86/split-global.ll Fri Aug 18 18:15:06 2017<br class="">@@ -39,7 +39,7 @@ target triple = "x86_64-apple-macosx10.1<br class=""> !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4)<br class=""> !2 = !DIFile(filename: "g.c", directory: "/")<br class=""> !3 = !{}<br class="">-!4 = !{!12, !13, !14, !15, !17, !18}<br class="">+!4 = !{!12, !13, !14, !15, !17, !18, !20}<br class=""> !5 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !2, line: 1, size: 64, elements: !6)<br class=""> !6 = !{!7, !9}<br class=""> !7 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !5, file: !2, line: 1, baseType: !8, size: 32)<br class="">@@ -58,3 +58,4 @@ target triple = "x86_64-apple-macosx10.1<br class=""> !18 = !DIGlobalVariableExpression(var: !19, expr: !DIExpression(DW_OP_constu, 2,<br class="">                                             <span class="Apple-converted-space"> </span>DW_OP_stack_value, DW_OP_LLVM_fragment, 32, 32))<br class=""> !19 = distinct !DIGlobalVariable(name: "full_const", scope: !1, file: !2, line: 1, type: !5, isLocal: false, isDefinition: true)<br class="">+!20 = !DIGlobalVariableExpression(var: !0)<br class=""></blockquote></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Should this be/is this valid ir?</div></div></blockquote><div><br class=""></div><div><br class=""></div>I think it is reasonable to support "dangling" global variables in the CU list to represent globals that have been optimized away. Not sure whether we should disallow having them there while they are still attached by global symbols.</div><div><br class=""></div><div>--adrian<br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a></blockquote></div></div></blockquote></div><br class=""></body></html>