[llvm] r342264 - Fix debug info for SelectionDAG legalization of DAG nodes with two results.

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 14 12:38:45 PDT 2018


Author: adrian
Date: Fri Sep 14 12:38:45 2018
New Revision: 342264

URL: http://llvm.org/viewvc/llvm-project?rev=342264&view=rev
Log:
Fix debug info for SelectionDAG legalization of DAG nodes with two results.

This patch fixes the debug info handling for SelectionDAG legalization
of DAG nodes with two results. When an replaced SDNode has more than
one result, transferDbgValues was always copying the SDDbgValue from
the first result and attaching them to all members. In reality
SelectionDAG::ReplaceAllUsesWith() is given an array of SDNodes
(though the type signature doesn't make this obvious (cf. the call
site code in ReplaceNode()).

rdar://problem/44162227

Differential Revision: https://reviews.llvm.org/D52112

Added:
    llvm/trunk/test/DebugInfo/X86/sdag-legalize-multires.ll
Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=342264&r1=342263&r2=342264&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Sep 14 12:38:45 2018
@@ -7797,7 +7797,7 @@ void SelectionDAG::ReplaceAllUsesWith(SD
 
   // Preserve Debug Info.
   for (unsigned i = 0, e = From->getNumValues(); i != e; ++i)
-    transferDbgValues(SDValue(From, i), *To);
+    transferDbgValues(SDValue(From, i), To[i]);
 
   // Iterate over just the existing users of From. See the comments in
   // the ReplaceAllUsesWith above.

Added: llvm/trunk/test/DebugInfo/X86/sdag-legalize-multires.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/sdag-legalize-multires.ll?rev=342264&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/X86/sdag-legalize-multires.ll (added)
+++ llvm/trunk/test/DebugInfo/X86/sdag-legalize-multires.ll Fri Sep 14 12:38:45 2018
@@ -0,0 +1,47 @@
+; RUN: llc -O0 %s -stop-after=livedebugvars -o - | FileCheck %s
+; This is a hand-crafted example modified after some Swift compiler output.
+; Test that SelectionDAG legalization of DAG nodes with two results
+; transfers debug info correctly.
+
+source_filename = "/tmp/sincos.ll"
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.13.0"
+
+declare float @llvm.cos.f32(float)
+declare float @llvm.sin.f32(float)
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+declare swiftcc void @g(float, float)
+
+; CHECK: ![[RCOS:.*]] = !DILocalVariable(name: "rcos"
+; CHECK: ![[RSIN:.*]] = !DILocalVariable(name: "rsin"
+
+define hidden swiftcc void @f() #0 !dbg !8 {
+entry:
+  ; CHECK: CALL64pcrel32 &__sincosf_stret
+  %0 = call float @llvm.cos.f32(float 1.500000e+00), !dbg !13
+  ; CHECK: $xmm1 = MOVAPSrr $xmm0
+  call void @llvm.dbg.value(metadata float %0, metadata !15, metadata !DIExpression()), !dbg !13
+  ; CHECK: DBG_VALUE debug-use {{.*}}$xmm1, {{.*}}, ![[RSIN]], !DIExpression(),
+  %1 = call float @llvm.sin.f32(float 1.500000e+00), !dbg !13
+  call void @llvm.dbg.value(metadata float %1, metadata !11, metadata !DIExpression()), !dbg !13
+  ; CHECK: DBG_VALUE debug-use {{.*}}$xmm0, {{.*}}, ![[RCOS]], !DIExpression(),
+  call void @g(float %0, float %1), !dbg !13
+  ret void, !dbg !13
+}
+
+attributes #0 = { noinline nounwind optnone ssp uwtable "target-features"="+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
+!1 = !DIFile(filename: "sincos.ll", directory: "/")
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0)
+!9 = !DISubroutineType(types: !10)
+!10 = !{null}
+!11 = !DILocalVariable(name: "rsin", scope: !8, file: !1, line: 3, type: !12)
+!12 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
+!13 = !DILocation(line: 3, scope: !8)
+!15 = !DILocalVariable(name: "rcos", scope: !8, file: !1, line: 4, type: !12)




More information about the llvm-commits mailing list