Hi Adrian,<div><br></div><div>The test ‘DebugInfo/X86/<wbr>linear-dbg-value.ll’ seems to be running for non-x86 targets. Do you think it needs a ‘-mtriple x86’? Or is it generic enough to move out of the x86 directory?</div><div><br></div><div>thanks,</div><div>Aaron<br><div><br>On Friday, March 2, 2018, Adrian Prantl via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Fri Mar  2 14:59:51 2018<br>
New Revision: 326631<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=326631&view=rev" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=326631&view=rev</a><br>
Log:<br>
Add DBG_VALUE support to the linear DAG scheduler<br>
<br>
The fast/linear DAG scheduler doesn't lower DBG_VALUEs except for<br>
function entry nodes.<br>
<br>
Patch by Joshua Cranmer!<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D43028" target="_blank">https://reviews.llvm.org/<wbr>D43028</a><br>
<br>
Added:<br>
    llvm/trunk/test/DebugInfo/X86/<wbr>linear-dbg-value.ll<br>
Modified:<br>
    llvm/trunk/lib/CodeGen/<wbr>SelectionDAG/ScheduleDAGFast.<wbr>cpp<br>
<br>
Modified: llvm/trunk/lib/CodeGen/<wbr>SelectionDAG/ScheduleDAGFast.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp?rev=326631&r1=326630&r2=326631&view=diff" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>CodeGen/SelectionDAG/<wbr>ScheduleDAGFast.cpp?rev=<wbr>326631&r1=326630&r2=326631&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/CodeGen/<wbr>SelectionDAG/ScheduleDAGFast.<wbr>cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/<wbr>SelectionDAG/ScheduleDAGFast.<wbr>cpp Fri Mar  2 14:59:51 2018<br>
@@ -13,6 +13,7 @@<br>
<br>
 #include "InstrEmitter.h"<br>
 #include "ScheduleDAGSDNodes.h"<br>
+#include "SDNodeDbgValue.h"<br>
 #include "llvm/ADT/STLExtras.h"<br>
 #include "llvm/ADT/SmallSet.h"<br>
 #include "llvm/ADT/Statistic.h"<br>
@@ -767,12 +768,24 @@ ScheduleDAGLinearize::<wbr>EmitSchedule(Machi<br>
       dbgs() << "\n*** Final schedule ***\n";<br>
     });<br>
<br>
-  // FIXME: Handle dbg_values.<br>
   unsigned NumNodes = Sequence.size();<br>
+  MachineBasicBlock *BB = Emitter.getBlock();<br>
   for (unsigned i = 0; i != NumNodes; ++i) {<br>
     SDNode *N = Sequence[NumNodes-i-1];<br>
     DEBUG(N->dump(DAG));<br>
     Emitter.EmitNode(N, false, false, VRBaseMap);<br>
+<br>
+    // Emit any debug values associated with the node.<br>
+    if (N->getHasDebugValue()) {<br>
+      MachineBasicBlock::iterator InsertPos = Emitter.getInsertPos();<br>
+      for (auto DV : DAG->GetDbgValues(N)) {<br>
+        if (DV->isInvalidated())<br>
+          continue;<br>
+        if (auto *DbgMI = Emitter.EmitDbgValue(DV, VRBaseMap))<br>
+          BB->insert(InsertPos, DbgMI);<br>
+        DV->setIsInvalidated();<br>
+      }<br>
+    }<br>
   }<br>
<br>
   DEBUG(dbgs() << '\n');<br>
<br>
Added: llvm/trunk/test/DebugInfo/X86/<wbr>linear-dbg-value.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/linear-dbg-value.ll?rev=326631&view=auto" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/test/<wbr>DebugInfo/X86/linear-dbg-<wbr>value.ll?rev=326631&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/test/DebugInfo/X86/<wbr>linear-dbg-value.ll (added)<br>
+++ llvm/trunk/test/DebugInfo/X86/<wbr>linear-dbg-value.ll Fri Mar  2 14:59:51 2018<br>
@@ -0,0 +1,70 @@<br>
+; RUN: llc -stop-before=expand-isel-<wbr>pseudos -pre-RA-sched=linearize < %s | FileCheck %s<br>
+source_filename = "/Data/llvm/test/DebugInfo/<wbr>X86/linear-dbg-value.ll"<br>
+<br>
+; Function Attrs: nounwind readonly uwtable<br>
+define i32 @foo(i32* nocapture readonly %a, i32 %N) local_unnamed_addr #0 !dbg !6 {<br>
+entry:<br>
+  %cmp6 = icmp sgt i32 %N, 0, !dbg !11<br>
+  br i1 %cmp6, label %for.body.preheader, label %for.cond.cleanup, !dbg !15<br>
+<br>
+for.body.preheader:                               ; preds = %entry<br>
+  %wide.trip.count = zext i32 %N to i64<br>
+  br label %for.body, !dbg !17<br>
+<br>
+for.cond.cleanup.loopexit:                        ; preds = %for.body<br>
+  br label %for.cond.cleanup, !dbg !19<br>
+<br>
+for.cond.cleanup:                                 ; preds = %for.cond.cleanup.loopexit, %entry<br>
+  %x.0.lcssa = phi i32 [ 0, %entry ], [ %add, %for.cond.cleanup.loopexit ]<br>
+  ret i32 %x.0.lcssa, !dbg !19<br>
+<br>
+for.body:                                         ; preds = %for.body, %for.body.preheader<br>
+; CHECK: ![[X:[0-9]+]] = !DILocalVariable(name: "x",<br>
+; CHECK-LABEL: bb.3.for.body:<br>
+; CHECK: DBG_VALUE {{.*}} ![[X]], !DIExpression()<br>
+; CHECK: DBG_VALUE {{.*}} ![[X]], !DIExpression()<br>
+  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %for.body.preheader ]<br>
+  %x.07 = phi i32 [ %add, %for.body ], [ 0, %for.body.preheader ]<br>
+  %arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv, !dbg !17<br>
+  %0 = load i32, i32* %arrayidx, align 4, !dbg !17<br>
+  %add = add nsw i32 %0, %x.07, !dbg !17<br>
+  call void @llvm.dbg.value(metadata i32 %add, metadata !9, metadata !DIExpression()), !dbg !20<br>
+  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !21<br>
+  call void @llvm.dbg.value(metadata i32 %add, metadata !9, metadata !DIExpression()), !dbg !20<br>
+  %exitcond = icmp eq i64 %indvars.iv.next, %wide.trip.count, !dbg !11<br>
+  br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body, !dbg !15<br>
+}<br>
+<br>
+; Function Attrs: nounwind readnone speculatable<br>
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1<br>
+<br>
+attributes #0 = { nounwind readonly uwtable }<br>
+attributes #1 = { nounwind readnone speculatable }<br>
+<br>
+!<a href="http://llvm.dbg.cu" 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.1 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)<br>
+!1 = !DIFile(filename: "foo.c", directory: "/tmp")<br>
+!2 = !{}<br>
+!3 = !{i32 2, !"Dwarf Version", i32 4}<br>
+!4 = !{i32 2, !"Debug Info Version", i32 3}<br>
+!5 = !{!"clang version 4.0.1 "}<br>
+!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !8)<br>
+!7 = !DISubroutineType(types: !2)<br>
+!8 = !{!9}<br>
+!9 = !DILocalVariable(name: "x", scope: !6, file: !1, line: 3, type: !10)<br>
+!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)<br>
+!11 = !DILocation(line: 4, scope: !12)<br>
+!12 = !DILexicalBlockFile(scope: !13, file: !1, discriminator: 1)<br>
+!13 = distinct !DILexicalBlock(scope: !14, file: !1, line: 4, column: 3)<br>
+!14 = distinct !DILexicalBlock(scope: !6, file: !1, line: 4, column: 3)<br>
+!15 = !DILocation(line: 4, scope: !16)<br>
+!16 = !DILexicalBlockFile(scope: !14, file: !1, discriminator: 1)<br>
+!17 = !DILocation(line: 5, scope: !18)<br>
+!18 = distinct !DILexicalBlock(scope: !13, file: !1, line: 4, column: 31)<br>
+!19 = !DILocation(line: 7, scope: !6)<br>
+!20 = !DILocation(line: 3, scope: !6)<br>
+!21 = !DILocation(line: 4, scope: !22)<br>
+!22 = !DILexicalBlockFile(scope: !13, file: !1, discriminator: 3)<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>