<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Jun 20, 2017 at 8:51 AM Adrian Prantl <<a href="mailto:aprantl@apple.com">aprantl@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><blockquote type="cite"><div>On Jun 20, 2017, at 8:38 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:</div><br class="m_-5318965437009988461Apple-interchange-newline"><div><div dir="ltr" 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"><br><br><div class="gmail_quote"><div dir="ltr">On Fri, Jun 16, 2017 at 3:40 PM Adrian Prantl via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></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>Date: Fri Jun 16 17:40:04 2017<br>New Revision: 305599<br><br>URL:<span class="m_-5318965437009988461Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project?rev=305599&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=305599&view=rev</a><br>Log:<br>Improve the accuracy of variable ranges .debug_loc location lists.<br><br>For the following motivating example<br> <span class="m_-5318965437009988461Apple-converted-space"> </span>bool c();<br> <span class="m_-5318965437009988461Apple-converted-space"> </span>void f();<br> <span class="m_-5318965437009988461Apple-converted-space"> </span>bool start() {<br>   <span class="m_-5318965437009988461Apple-converted-space"> </span>bool result = c();<br>   <span class="m_-5318965437009988461Apple-converted-space"> </span>if (!c()) {<br>     <span class="m_-5318965437009988461Apple-converted-space"> </span>result = false;<br>     <span class="m_-5318965437009988461Apple-converted-space"> </span>goto exit;<br>   <span class="m_-5318965437009988461Apple-converted-space"> </span>}<br>   <span class="m_-5318965437009988461Apple-converted-space"> </span>f();<br>   <span class="m_-5318965437009988461Apple-converted-space"> </span>result = true;<br> <span class="m_-5318965437009988461Apple-converted-space"> </span>exit:<br>   <span class="m_-5318965437009988461Apple-converted-space"> </span>return result;<br> <span class="m_-5318965437009988461Apple-converted-space"> </span>}<br><br>we would previously generate a single DW_AT_const_value(1) because<br>only the DBG_VALUE in the second-to-last basic block survived<br>codegen. This patch improves the heuristic used to determine when a<br>DBG_VALUE is available at the beginning of its variable's enclosing<br>lexical scope:<br><br>- Stop giving singular constants blanket permission to take over the<br> <span class="m_-5318965437009988461Apple-converted-space"> </span>entire scope. There is still a special case for constants in the<br> <span class="m_-5318965437009988461Apple-converted-space"> </span>function prologue that we also miight want to retire later.<br><br>- Use the lexical scope information to determine available-at-entry<br> <span class="m_-5318965437009988461Apple-converted-space"> </span>instead of proximity to the function prologue.<br><br>After this patch we generate a location list with a more accurate<br>narrower availability for the constant true value. As a pleasant side<br>effect, we also generate inline locations instead of location lists<br>where a loacation covers the entire range of the enclosing lexical<br>scope.<br><br>Measured on compiling llc with four targets this doesn't have an<br>effect on compile time and reduces the size of the debug info for llc<br>by ~600K.<br><br><a>rdar://problem/30286912</a><br><br>Added:<br>   <span class="m_-5318965437009988461Apple-converted-space"> </span>llvm/trunk/test/DebugInfo/Generic/partial-constant.ll<br>Modified:<br>   <span class="m_-5318965437009988461Apple-converted-space"> </span>llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>   <span class="m_-5318965437009988461Apple-converted-space"> </span>llvm/trunk/test/DebugInfo/Generic/sugared-constants.ll<br>   <span class="m_-5318965437009988461Apple-converted-space"> </span>llvm/trunk/test/DebugInfo/MIR/X86/bit-piece-dh.mir<br>   <span class="m_-5318965437009988461Apple-converted-space"> </span>llvm/trunk/test/DebugInfo/X86/dbg-merge-loc-entry.ll<br>   <span class="m_-5318965437009988461Apple-converted-space"> </span>llvm/trunk/test/DebugInfo/X86/inlined-formal-parameter.ll<br>   <span class="m_-5318965437009988461Apple-converted-space"> </span>llvm/trunk/test/DebugInfo/X86/parameters.ll<br>   <span class="m_-5318965437009988461Apple-converted-space"> </span>llvm/trunk/test/DebugInfo/X86/pieces-3.ll<br>   <span class="m_-5318965437009988461Apple-converted-space"> </span>llvm/trunk/test/DebugInfo/X86/reference-argument.ll<br>   <span class="m_-5318965437009988461Apple-converted-space"> </span>llvm/trunk/test/DebugInfo/X86/this-stack_value.ll<br><br>Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>URL:<span class="m_-5318965437009988461Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=305599&r1=305598&r2=305599&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=305599&r1=305598&r2=305599&view=diff</a><br>==============================================================================<br>--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Jun 16 17:40:04 2017<br>@@ -972,16 +972,60 @@ DbgVariable *DwarfDebug::createConcreteV<br>   return ConcreteVariables.back().get();<br> }<br><br>-// Determine whether this DBG_VALUE is valid at the beginning of the function.<br>-static bool validAtEntry(const MachineInstr *MInsn) {<br>-  auto MBB = MInsn->getParent();<br>-  // Is it in the entry basic block?<br>-  if (!MBB->pred_empty())<br>+/// Determine whether a *singular* DBG_VALUE is valid for the entirety of its<br>+/// enclosing lexical scope. The check ensures there are no other instructions<br>+/// in the same lexical scope preceding the DBG_VALUE and that its range is<br>+/// either open or otherwise rolls off the end of the scope.<br>+static bool validThroughout(LexicalScopes &LScopes,<br>+                            const MachineInstr *DbgValue,<br>+                            const MachineInstr *RangeEnd) {<br>+  assert(DbgValue->getDebugLoc() && "DBG_VALUE without a debug location");<br>+  auto MBB = DbgValue->getParent();<br>+  auto DL = DbgValue->getDebugLoc();<br>+  auto *LScope = LScopes.findLexicalScope(DL);<br>+  // Scope doesn't exist; this is a dead DBG_VALUE.<br>+  if (!LScope)<br>     return false;<br>-  for (MachineBasicBlock::const_reverse_iterator I(MInsn); I != MBB->rend(); ++I)<br>-    if (!(I->isDebugValue() || I->getFlag(MachineInstr::FrameSetup)))<br>+  auto &LSRange = LScope->getRanges();<br>+  if (LSRange.size() == 0)<br>+    return false;<br>+<br>+  // Determine if the DBG_VALUE is valid at the beginning of its lexical block.<br>+  const MachineInstr *LScopeBegin = LSRange.front().first;<br>+  // Early exit if the lexical scope begins outside of the current block.<br>+  if (LScopeBegin->getParent() != MBB)<br>+    return false;<br>+  MachineBasicBlock::const_reverse_iterator Pred(DbgValue);<br>+  for (++Pred; Pred != MBB->rend(); ++Pred) {<br>+    if (Pred->getFlag(MachineInstr::FrameSetup))<br>+      break;<br>+    auto PredDL = Pred->getDebugLoc();<br>+    if (!PredDL || Pred->isDebugValue())<br>+      continue;<br>+    // Check whether the instruction preceding the DBG_VALUE is in the same<br>+    // (sub)scope as the DBG_VALUE.<br>+    if (DL->getScope() == PredDL->getScope() ||<br>+        LScope->dominates(LScopes.findLexicalScope(PredDL)))<br></blockquote><div><br>Just a heads up, Google internal test infrastructure is seeing failures here ^ (well, inside 'dominates' actually) when findLexicalScope returns null on this line.<br><br>The repro clang cc1 command is: <p class="m_-5318965437009988461inbox-inbox-p1"><span class="m_-5318965437009988461inbox-inbox-s1">clang-tot -cc1 -triple aarch64-linux-gnu -emit-obj<span class="m_-5318965437009988461inbox-inbox-Apple-converted-space"> <span class="m_-5318965437009988461Apple-converted-space"> </span></span>-relaxed-aliasing<span class="m_-5318965437009988461inbox-inbox-Apple-converted-space"> <span class="m_-5318965437009988461Apple-converted-space"> </span></span>-debug-info-kind=limited<span class="m_-5318965437009988461inbox-inbox-Apple-converted-space">   <span class="m_-5318965437009988461Apple-converted-space"> </span></span>-O2 -w -std=gnu++11 -o /tmp/x.o -x c++ crash.ii<br><br>Though I don't have a public reduced test case yet - creduce uis working on it (~75% reduced overnight... but chugging along pretty slow now). I'll provide it when I've got something.<br></span></p></div></div></div></div></blockquote><div><br></div></div></div><div style="word-wrap:break-word"><div><div>Thanks for the heads-up.! I'm assuming that </div><div><br></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255);font-size:11px"><span style="font-variant-ligatures:no-common-ligatures"><b>diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp</b></span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255);font-size:11px"><span style="font-variant-ligatures:no-common-ligatures"><b>index d392e372863..0830c78b6ed 100644</b></span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255);font-size:11px"><span style="font-variant-ligatures:no-common-ligatures"><b>--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp</b></span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255);font-size:11px"><span style="font-variant-ligatures:no-common-ligatures"><b>+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp</b></span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255);font-size:11px"><span style="font-variant-ligatures:no-common-ligatures;color:#33bbc8">@@ -1004,8 +1004,10 @@</span><span style="font-variant-ligatures:no-common-ligatures"> static bool validThroughout(LexicalScopes &LScopes,</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255);font-size:11px"><span style="font-variant-ligatures:no-common-ligatures">       continue;</span></div></div></div><div style="word-wrap:break-word"><div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255);font-size:11px"><span style="font-variant-ligatures:no-common-ligatures">     // Check whether the instruction preceding the DBG_VALUE is in the same</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255);font-size:11px"><span style="font-variant-ligatures:no-common-ligatures">     // (sub)scope as the DBG_VALUE.</span></div></div></div><div style="word-wrap:break-word"><div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(195,55,32);background-color:rgb(255,255,255);font-size:11px"><span style="font-variant-ligatures:no-common-ligatures">-    if (DL->getScope() == PredDL->getScope() ||</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(195,55,32);background-color:rgb(255,255,255);font-size:11px"><span style="font-variant-ligatures:no-common-ligatures">-        LScope->dominates(LScopes.findLexicalScope(PredDL)))</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(52,188,38);background-color:rgb(255,255,255);font-size:11px"><span style="font-variant-ligatures:no-common-ligatures">+    if (DL->getScope() == PredDL->getScope())</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(52,188,38);background-color:rgb(255,255,255);font-size:11px"><span style="font-variant-ligatures:no-common-ligatures">+      return false;</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(52,188,38);background-color:rgb(255,255,255);font-size:11px"><span style="font-variant-ligatures:no-common-ligatures">+    auto *PredScope = LScopes.findLexicalScope(PredDL);</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(52,188,38);background-color:rgb(255,255,255);font-size:11px"><span style="font-variant-ligatures:no-common-ligatures">+    if (!PredScope || LScope->dominates(PredScope))</span></div><div style="margin:0px;line-height:normal;font-family:Menlo;background-color:rgb(255,255,255);font-size:11px"><span style="font-variant-ligatures:no-common-ligatures">       return false;</span></div><div style="font-size:9px"><span style="font-family:Menlo;font-size:11px;background-color:rgb(255,255,255)">   </span><span style="font-family:Menlo;font-size:11px;background-color:rgb(255,255,255)">}</span></div><div><br></div><div>fixes the crash?</div></div></div></blockquote><div><br>Haven't tried - I'd guess that'd probably silence the issue.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div> This just adds a defensive check for nullptr here and add a safe 'return false' but I would like to understand how this is possible since we should have visited the previous scope before.</div></div></div></blockquote><div><br>Yeah, that'd be my concern - making sure the fix is principled.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div> I assume that the previous instruction's scope has no variable in it?</div></div></div></blockquote><div><br>Haven't looked yet - just reducing for now.<br><br>- Dave<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div><br></div><div>-- adrian</div></div></div><div style="word-wrap:break-word"><div><blockquote type="cite"><div><div dir="ltr" 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"><div class="gmail_quote"><div><p class="m_-5318965437009988461inbox-inbox-p1"><span class="m_-5318965437009988461inbox-inbox-s1">I mention it now in case you're seeing similar things or want to pre-emptively revert to avoid the possibility.</span></p> </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">       return false;<br>-  return true;<br>+  }<br>+<br>+  // If the range of the DBG_VALUE is open-ended, report success.<br>+  if (!RangeEnd)<br>+    return true;<br>+<br>+  // Fail if there are instructions belonging to our scope in another block.<br>+  const MachineInstr *LScopeEnd = LSRange.back().second;<br>+  if (LScopeEnd->getParent() != MBB)<br>+    return false;<br>+<br>+  // Single, constant DBG_VALUEs in the prologue are promoted to be live<br>+  // throughout the function. This is a hack, presumably for DWARF v2 and not<br>+  // necessarily correct. It would be much better to use a dbg.declare instead<br>+  // if we know the constant is live throughout the scope.<br>+  if (DbgValue->getOperand(0).isImm() && MBB->pred_empty())<br>+    return true;<br>+<br>+  return false;<br> }<br><br> // Find variables for each lexical scope.<br>@@ -1016,11 +1060,9 @@ void DwarfDebug::collectVariableInfo(Dwa<br>     const MachineInstr *MInsn = Ranges.front().first;<br>     assert(MInsn->isDebugValue() && "History must begin with debug value");<br><br>-    // Check if there is a single DBG_VALUE, valid throughout the function.<br>-    // A single constant is also considered valid for the entire function.<br>+    // Check if there is a single DBG_VALUE, valid throughout the var's scope.<br>     if (Ranges.size() == 1 &&<br>-        (MInsn->getOperand(0).isImm() ||<br>-         (validAtEntry(MInsn) && Ranges.front().second == nullptr))) {<br>+        validThroughout(LScopes, MInsn, Ranges.front().second)) {<br>       RegVar->initializeDbgValue(MInsn);<br>       continue;<br>     }<br><br>Added: llvm/trunk/test/DebugInfo/Generic/partial-constant.ll<br>URL:<span class="m_-5318965437009988461Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/partial-constant.ll?rev=305599&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/partial-constant.ll?rev=305599&view=auto</a><br>==============================================================================<br>--- llvm/trunk/test/DebugInfo/Generic/partial-constant.ll (added)<br>+++ llvm/trunk/test/DebugInfo/Generic/partial-constant.ll Fri Jun 16 17:40:04 2017<br>@@ -0,0 +1,82 @@<br>+; RUN: %llc_dwarf -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s<br>+; Generated at -O2 from:<br>+; bool c();<br>+; void f();<br>+; bool start() {<br>+;   bool result = c();<br>+;   if (!c()) {<br>+;     result = false;<br>+;     goto exit;<br>+;   }<br>+;   f();<br>+;   result = true;<br>+; exit:<br>+;   return result;<br>+; }<br>+;<br>+; The constant should NOT be available for the entire function.<br>+; CHECK-NOT: DW_AT_const_value<br>+; CHECK: .debug_loc<br>+; CHECK: Location description: 10 01 9f<br>+;                              constu 0x00000001, stack-value<br>+source_filename = "test.ii"<br>+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"<br>+target triple = "x86_64-apple-macosx10.12.0"<br>+<br>+; Function Attrs: noimplicitfloat noredzone nounwind optsize<br>+define zeroext i1 @_Z5startv() local_unnamed_addr #0 !dbg !7 {<br>+entry:<br>+  %call = tail call zeroext i1 @_Z1cv() #3, !dbg !13<br>+  %call1 = tail call zeroext i1 @_Z1cv() #3, !dbg !14<br>+  br i1 %call1, label %if.end, label %exit, !dbg !16<br>+<br>+if.end:                                           ; preds = %entry<br>+  tail call void @_Z1fv() #3, !dbg !17<br>+  tail call void @llvm.dbg.value(metadata i8 1, i64 0, metadata !12, metadata !18), !dbg !19<br>+  br label %exit, !dbg !20<br>+<br>+exit:                                             ; preds = %entry, %if.end<br>+  %result.0 = phi i1 [ true, %if.end ], [ false, %entry ]<br>+  ret i1 %result.0, !dbg !21<br>+}<br>+<br>+; Function Attrs: noimplicitfloat noredzone optsize<br>+declare zeroext i1 @_Z1cv() local_unnamed_addr #1<br>+<br>+; Function Attrs: noimplicitfloat noredzone optsize<br>+declare void @_Z1fv() local_unnamed_addr #1<br>+<br>+; Function Attrs: nounwind readnone speculatable<br>+declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2<br>+<br>+attributes #0 = { noimplicitfloat noredzone nounwind optsize }<br>+attributes #1 = { noimplicitfloat noredzone optsize }<br>+attributes #2 = { nounwind readnone speculatable }<br>+attributes #3 = { nobuiltin noimplicitfloat noredzone nounwind optsize }<br>+<br>+!<a href="http://llvm.dbg.cu/" rel="noreferrer" target="_blank">llvm.dbg.cu</a><span class="m_-5318965437009988461Apple-converted-space"> </span>= !{!0}<br>+!llvm.module.flags = !{!3, !4, !5}<br>+!llvm.ident = !{!6}<br>+<br>+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 5.0.0 (trunk 303873) (llvm/trunk 303897)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)<br>+!1 = !DIFile(filename: "test.ii", directory: "/")<br>+!2 = !{}<br>+!3 = !{i32 2, !"Dwarf Version", i32 4}<br>+!4 = !{i32 2, !"Debug Info Version", i32 3}<br>+!5 = !{i32 1, !"wchar_size", i32 4}<br>+!6 = !{!"clang version 5.0.0 (trunk 303873) (llvm/trunk 303897)"}<br>+!7 = distinct !DISubprogram(name: "start", linkageName: "_Z5startv", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !11)<br>+!8 = !DISubroutineType(types: !9)<br>+!9 = !{!10}<br>+!10 = !DIBasicType(name: "bool", size: 8, encoding: DW_ATE_boolean)<br>+!11 = !{!12}<br>+!12 = !DILocalVariable(name: "result", scope: !7, file: !1, line: 4, type: !10)<br>+!13 = !DILocation(line: 4, column: 17, scope: !7)<br>+!14 = !DILocation(line: 5, column: 8, scope: !15)<br>+!15 = distinct !DILexicalBlock(scope: !7, file: !1, line: 5, column: 7)<br>+!16 = !DILocation(line: 5, column: 7, scope: !7)<br>+!17 = !DILocation(line: 9, column: 3, scope: !7)<br>+!18 = !DIExpression()<br>+!19 = !DILocation(line: 4, column: 8, scope: !7)<br>+!20 = !DILocation(line: 10, column: 3, scope: !7)<br>+!21 = !DILocation(line: 12, column: 3, scope: !7)<br><br>Modified: llvm/trunk/test/DebugInfo/Generic/sugared-constants.ll<br>URL:<span class="m_-5318965437009988461Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/sugared-constants.ll?rev=305599&r1=305598&r2=305599&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/sugared-constants.ll?rev=305599&r1=305598&r2=305599&view=diff</a><br>==============================================================================<br>--- llvm/trunk/test/DebugInfo/Generic/sugared-constants.ll (original)<br>+++ llvm/trunk/test/DebugInfo/Generic/sugared-constants.ll Fri Jun 16 17:40:04 2017<br>@@ -3,47 +3,23 @@<br> ; RUN: %llc_dwarf -O0 -filetype=obj %s -o - | llvm-dwarfdump -debug-dump=info - | FileCheck %s<br> ; Use correct signedness when emitting constants of derived (sugared) types.<br><br>-; Test compiled to IR from clang with -O1 and the following source:<br>-<br>-; void func(int);<br>-; void func(unsigned);<br>-; void func(char16_t);<br>-; int main() {<br>-;   const int i = 42;<br>-;   func(i);<br>-;   const unsigned j = 117;<br>-;   func(j);<br>-;   char16_t c = 7;<br>-;   func(c);<br>-; }<br>-<br> ; CHECK: DW_AT_const_value [DW_FORM_sdata] (42)<br> ; CHECK: DW_AT_const_value [DW_FORM_udata] (117)<br> ; CHECK: DW_AT_const_value [DW_FORM_udata] (7)<br><br> ; Function Attrs: uwtable<br>-define i32 @main() #0 !dbg !4 {<br>+define void @main() #0 !dbg !4 {<br> entry:<br>   tail call void @llvm.dbg.value(metadata i32 42, i64 0, metadata !10, metadata !DIExpression()), !dbg !21<br>-  tail call void @_Z4funci(i32 42), !dbg !22<br>   tail call void @llvm.dbg.value(metadata i32 117, i64 0, metadata !12, metadata !DIExpression()), !dbg !24<br>-  tail call void @_Z4funcj(i32 117), !dbg !25<br>   tail call void @llvm.dbg.value(metadata i16 7, i64 0, metadata !15, metadata !DIExpression()), !dbg !27<br>-  tail call void @_Z4funcDs(i16 zeroext 7), !dbg !28<br>-  ret i32 0, !dbg !29<br>+  ret void, !dbg !29<br> }<br><br>-declare void @_Z4funci(i32) #1<br>-<br>-declare void @_Z4funcj(i32) #1<br>-<br>-declare void @_Z4funcDs(i16 zeroext) #1<br>-<br> ; Function Attrs: nounwind readnone<br> declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2<br><br>-attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }<br>-attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }<br>+attributes #0 = { uwtable }<br> attributes #2 = { nounwind readnone }<br><br> !<a href="http://llvm.dbg.cu/" rel="noreferrer" target="_blank">llvm.dbg.cu</a><span class="m_-5318965437009988461Apple-converted-space"> </span>= !{!0}<br><br>Modified: llvm/trunk/test/DebugInfo/MIR/X86/bit-piece-dh.mir<br>URL:<span class="m_-5318965437009988461Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/MIR/X86/bit-piece-dh.mir?rev=305599&r1=305598&r2=305599&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/MIR/X86/bit-piece-dh.mir?rev=305599&r1=305598&r2=305599&view=diff</a><br>==============================================================================<br>--- llvm/trunk/test/DebugInfo/MIR/X86/bit-piece-dh.mir (original)<br>+++ llvm/trunk/test/DebugInfo/MIR/X86/bit-piece-dh.mir Fri Jun 16 17:40:04 2017<br>@@ -1,13 +1,9 @@<br>-# RUN: llc -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s<br>+# RUN: llc -filetype=obj -o - %s | llvm-dwarfdump --debug-dump=info - | FileCheck %s<br> # CHECK: .debug_info contents:<br> # CHECK: DW_TAG_variable<br>-# CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset]      ([[OFS:.*]])<br>-# CHECK-NEXT: DW_AT_name {{.*}}"dh"<br>-# CHECK: .debug_loc contents:<br>-# CHECK: [[OFS]]: Beginning address offset: 0x0000000000000002<br>-# CHECK:             Ending address offset: 0x000000000000000c<br>-# CHECK:              Location description: 51 9d 08 08<br> #                                           rdx, bit-piece 8 8<br>+# CHECK-NEXT: DW_AT_location {{.*}}         51 9d 08 08<br>+# CHECK-NEXT: DW_AT_name {{.*}}"dh"<br> --- |<br>   ; Manually created after:<br>   ; char f(int i) {<br><br>Modified: llvm/trunk/test/DebugInfo/X86/dbg-merge-loc-entry.ll<br>URL:<span class="m_-5318965437009988461Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dbg-merge-loc-entry.ll?rev=305599&r1=305598&r2=305599&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/dbg-merge-loc-entry.ll?rev=305599&r1=305598&r2=305599&view=diff</a><br>==============================================================================<br>--- llvm/trunk/test/DebugInfo/X86/dbg-merge-loc-entry.ll (original)<br>+++ llvm/trunk/test/DebugInfo/X86/dbg-merge-loc-entry.ll Fri Jun 16 17:40:04 2017<br>@@ -6,6 +6,7 @@<br> target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"<br> target triple = "x86_64-apple-darwin8"<br><br>+; Test that consecutive, identical DBG_VALUEs are merged.<br> ;CHECK: DW_AT_location{{.*}}(<0x1> 55 )<br><br> %0 = type { i64, i1 }<br>@@ -19,6 +20,7 @@ entry:<br>   br i1 undef, label %bb2, label %bb4, !dbg !22<br><br> bb2:                                              ; preds = %entry<br>+  tail call void @llvm.dbg.value(metadata i128 %u, i64 0, metadata !14, metadata !DIExpression()), !dbg !15<br>   br label %bb4, !dbg !23<br><br> bb4:                                              ; preds = %bb2, %entry<br><br>Modified: llvm/trunk/test/DebugInfo/X86/inlined-formal-parameter.ll<br>URL:<span class="m_-5318965437009988461Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/inlined-formal-parameter.ll?rev=305599&r1=305598&r2=305599&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/inlined-formal-parameter.ll?rev=305599&r1=305598&r2=305599&view=diff</a><br>==============================================================================<br>--- llvm/trunk/test/DebugInfo/X86/inlined-formal-parameter.ll (original)<br>+++ llvm/trunk/test/DebugInfo/X86/inlined-formal-parameter.ll Fri Jun 16 17:40:04 2017<br>@@ -1,5 +1,5 @@<br> ; RUN: llc -filetype=obj -o %t.o %s<br>-; RUN: llvm-dwarfdump -debug-dump=info %t.o | FileCheck %s<br>+; RUN: llvm-dwarfdump %t.o | FileCheck %s<br><br> ; Testcase generated using 'clang -g -O2 -S -emit-llvm' from the following:<br> ;; void sink(void);<br>@@ -10,6 +10,7 @@<br> ;; }<br><br> ; Check that we have formal parameters for 'a' in both inlined subroutines.<br>+; CHECK: .debug_info<br> ; CHECK:       DW_TAG_inlined_subroutine<br> ; CHECK-NEXT:    DW_AT_abstract_origin {{.*}} "bar"<br> ; CHECK:         DW_TAG_formal_parameter<br>@@ -18,9 +19,11 @@<br> ; CHECK:       DW_TAG_inlined_subroutine<br> ; CHECK-NEXT:    DW_AT_abstract_origin {{.*}} "bar"<br> ; CHECK:         DW_TAG_formal_parameter<br>-; CHECK-NEXT:      DW_AT_const_value<br>+; CHECK-NEXT:      DW_AT_location [DW_FORM_data4]      (0x00000000)<br> ; CHECK-NEXT:      DW_AT_abstract_origin {{.*}} "a"<br>-<br>+;<br>+; CHECK: .debug_loc<br>+; CHECK: Location description: 11 00<br> target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"<br> target triple = "x86_64-apple-darwin"<br><br>@@ -34,13 +37,12 @@ entry:<br>   ret void, !dbg !24<br> }<br><br>-declare void @sink() #1<br>+declare void @sink()<br><br> ; Function Attrs: nounwind readnone<br> declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2<br><br>-attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" }<br>-attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="core2" "unsafe-fp-math"="false" "use-soft-float"="false" }<br>+attributes #0 = { nounwind ssp uwtable  }<br> attributes #2 = { nounwind readnone }<br> attributes #3 = { nounwind }<br><br><br>Modified: llvm/trunk/test/DebugInfo/X86/parameters.ll<br>URL:<span class="m_-5318965437009988461Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/parameters.ll?rev=305599&r1=305598&r2=305599&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/parameters.ll?rev=305599&r1=305598&r2=305599&view=diff</a><br>==============================================================================<br>--- llvm/trunk/test/DebugInfo/X86/parameters.ll (original)<br>+++ llvm/trunk/test/DebugInfo/X86/parameters.ll Fri Jun 16 17:40:04 2017<br>@@ -24,8 +24,9 @@<br><br> ; CHECK: debug_info contents<br> ; 0x74 is DW_OP_breg4, showing that the parameter is accessed indirectly<br>-; (with a zero offset) from the register parameter<br>-; CHECK: DW_AT_location [DW_FORM_data4]        ([[F_LOC:0x[0-9]*]])<br>+; (with a zero offset) from the register parameter.<br>+; CHECK: DW_AT_location {{.*}} 74 00 06<br>+<br> ; CHECK-NOT: DW_TAG<br> ; CHECK: DW_AT_name{{.*}} = "f"<br> ;<br>@@ -34,9 +35,6 @@<br> ; CHECK: DW_AT_name{{.*}} = "g"<br> ;<br> ; CHECK: debug_loc contents<br>-; CHECK:         [[F_LOC]]: Beginning<br>-; CHECK-NEXT:               Ending<br>-; CHECK-NEXT: Location description: 74 00<br> ; CHECK:         [[G_LOC]]: Beginning<br> ; CHECK-NEXT:               Ending<br> ; CHECK-NEXT: Location description: 74 00<br>@@ -77,11 +75,10 @@ if.end:<br>   ret void, !dbg !32<br> }<br><br>-declare void @_ZN7pr147634sinkEPv(i8*) #2<br>+declare void @_ZN7pr147634sinkEPv(i8*)<br><br>-attributes #0 = { uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }<br>+attributes #0 = { uwtable }<br> attributes #1 = { nounwind readnone }<br>-attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }<br><br> !<a href="http://llvm.dbg.cu/" rel="noreferrer" target="_blank">llvm.dbg.cu</a><span class="m_-5318965437009988461Apple-converted-space"> </span>= !{!0}<br> !llvm.module.flags = !{!21, !33}<br><br>Modified: llvm/trunk/test/DebugInfo/X86/pieces-3.ll<br>URL:<span class="m_-5318965437009988461Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/pieces-3.ll?rev=305599&r1=305598&r2=305599&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/pieces-3.ll?rev=305599&r1=305598&r2=305599&view=diff</a><br>==============================================================================<br>--- llvm/trunk/test/DebugInfo/X86/pieces-3.ll (original)<br>+++ llvm/trunk/test/DebugInfo/X86/pieces-3.ll Fri Jun 16 17:40:04 2017<br>@@ -19,7 +19,9 @@<br> ; CHECK-NEXT:   DW_AT_location [DW_FORM_data4]        ([[LOC1:.*]])<br> ; CHECK-NEXT:   DW_AT_name {{.*}}"outer"<br> ; CHECK: DW_TAG_variable<br>-; CHECK-NEXT:   DW_AT_location [DW_FORM_data4]        ([[LOC2:.*]])<br>+; CHECK-NEXT:   DW_AT_location<br>+;                                     rsi, piece 0x00000004<br>+; CHECK-SAME:                         54 93 04<br> ; CHECK-NEXT:   "i1"<br> ;<br> ; CHECK: .debug_loc<br>@@ -32,10 +34,6 @@<br> ; CHECK:           Beginning address offset: 0x0000000000000004<br> ; CHECK-NEXT:         Ending address offset: 0x0000000000000008<br> ; CHECK-NEXT: Location description: 55 93 08 93 04 54 93 04<br>-; CHECK: [[LOC2]]: Beginning address offset: 0x0000000000000004<br>-; CHECK-NEXT:         Ending address offset: 0x0000000000000008<br>-;                                     rsi, piece 0x00000004<br>-; CHECK-NEXT:   Location description: 54 93 04<br><br> ;<br> ; ModuleID = '/Volumes/Data/llvm/test/DebugInfo/X86/sroasplit-2.ll'<br>@@ -48,6 +46,7 @@ define i32 @foo(i64 %outer.coerce0, i64<br>   call void @llvm.dbg.declare(metadata !{null}, metadata !27, metadata !28), !dbg !26<br>   call void @llvm.dbg.value(metadata i64 %outer.coerce1, i64 0, metadata !29, metadata !30), !dbg !26<br>   call void @llvm.dbg.declare(metadata !{null}, metadata !31, metadata !32), !dbg !26<br>+  ; The 'trunc' generates no extra code, thus i1 is visible throughout its scope.<br>   %outer.sroa.1.8.extract.trunc = trunc i64 %outer.coerce1 to i32, !dbg !33<br>   call void @llvm.dbg.value(metadata i32 %outer.sroa.1.8.extract.trunc, i64 0, metadata !34, metadata !35), !dbg !33<br>   %outer.sroa.1.12.extract.shift = lshr i64 %outer.coerce1, 32, !dbg !33<br><br>Modified: llvm/trunk/test/DebugInfo/X86/reference-argument.ll<br>URL:<span class="m_-5318965437009988461Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/reference-argument.ll?rev=305599&r1=305598&r2=305599&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/reference-argument.ll?rev=305599&r1=305598&r2=305599&view=diff</a><br>==============================================================================<br>--- llvm/trunk/test/DebugInfo/X86/reference-argument.ll (original)<br>+++ llvm/trunk/test/DebugInfo/X86/reference-argument.ll Fri Jun 16 17:40:04 2017<br>@@ -1,4 +1,5 @@<br>-; RUN: llc -mtriple=x86_64-apple-macosx10.9.0 -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=all - | FileCheck %s<br>+; RUN: llc -mtriple=x86_64-apple-macosx10.9.0 -filetype=obj -O0 < %s \<br>+; RUN:   | llvm-dwarfdump -debug-dump=info - | FileCheck %s<br> ; ModuleID = 'aggregate-indirect-arg.cpp'<br> ; extracted from debuginfo-tests/aggregate-indirect-arg.cpp<br><br>@@ -11,11 +12,10 @@<br> ; CHECK:       DW_AT_name {{.*}} "this"<br> ; CHECK-NOT:   DW_TAG_subprogram<br> ; CHECK:     DW_TAG_formal_parameter<br>-; CHECK-NEXT:  DW_AT_location [DW_FORM_data4]  (0x00000000)<br>-; CHECK-NEXT:  DW_AT_name {{.*}} "v"<br>-; CHECK: .debug_loc contents:<br>+; CHECK-NEXT:  DW_AT_location<br> ;                                rsi+0<br>-; CHECK:   Location description: 74 00<br>+; CHECK-SAME:                    74 00<br>+; CHECK-NEXT:  DW_AT_name {{.*}} "v"<br><br> target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"<br> target triple = "x86_64-apple-macosx10.9.0"<br><br>Modified: llvm/trunk/test/DebugInfo/X86/this-stack_value.ll<br>URL:<span class="m_-5318965437009988461Apple-converted-space"> </span><a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/this-stack_value.ll?rev=305599&r1=305598&r2=305599&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/this-stack_value.ll?rev=305599&r1=305598&r2=305599&view=diff</a><br>==============================================================================<br>--- llvm/trunk/test/DebugInfo/X86/this-stack_value.ll (original)<br>+++ llvm/trunk/test/DebugInfo/X86/this-stack_value.ll Fri Jun 16 17:40:04 2017<br>@@ -1,5 +1,5 @@<br> ; RUN: llc -filetype=asm -o - %s | FileCheck %s --check-prefix=ASM<br>-; RUN: llc -filetype=obj -o - %s | llvm-dwarfdump - | FileCheck %s<br>+; RUN: llc -filetype=obj -o - %s | llvm-dwarfdump --debug-dump=info - | FileCheck %s<br> ;<br> ; Generated at -O2 from:<br> ;   struct B;<br>@@ -18,7 +18,7 @@<br> ; modified by the debugger.<br> ;<br> ; ASM: [DW_OP_stack_value]<br>-; CHECK:  Location description: 70 00 9f<br>+; CHECK:  DW_AT_location {{.*}} 70 00 9f<br> ;                               rax+0, stack-value<br> source_filename = "ab.cpp"<br> target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"<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></blockquote></div></div></div></blockquote></div></div></blockquote></div></div>