[PATCH] D44546: [SelectionDAG] Transfer DbgValues when integer operations are promoted

Aaron Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 16 15:52:42 PDT 2018


asmith updated this revision to Diff 138790.
asmith edited the summary of this revision.
Herald added subscribers: kristof.beyls, javed.absar.

https://reviews.llvm.org/D44546

Files:
  lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
  test/CodeGen/ARM/debug-info-d16-reg.ll
  test/DebugInfo/AArch64/dbg-value-i8.ll


Index: test/DebugInfo/AArch64/dbg-value-i8.ll
===================================================================
--- /dev/null
+++ test/DebugInfo/AArch64/dbg-value-i8.ll
@@ -0,0 +1,63 @@
+; RUN: llc < %s | FileCheck %s
+; ModuleID = 'debug_value-i8.bc'
+source_filename = "debug_value.c"
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64"
+
+; When ISel promotes the result of i8 add, the attached dbg.value shouldn't be dropped.
+; CHECK: DEBUG_VALUE: bar:t
+; Function Attrs: nounwind
+define dso_local i32 @bar(i32*, i32) local_unnamed_addr #0 !dbg !10 {
+  call void @llvm.dbg.value(metadata i32* %0, metadata !15, metadata !DIExpression()), !dbg !18
+  call void @llvm.dbg.value(metadata i32 %1, metadata !16, metadata !DIExpression()), !dbg !19
+  %3 = trunc i32 %1 to i8, !dbg !20
+  %4 = add i8 %3, 97, !dbg !20
+  call void @llvm.dbg.value(metadata i8 %4, metadata !17, metadata !DIExpression()), !dbg !21
+  %5 = zext i8 %4 to i32, !dbg !22
+  tail call void @foo1(i32* %0, i32 %5) #3, !dbg !23
+  tail call void @foo2(i32* %0, i8 %4) #3, !dbg !24
+  ret i32 undef, !dbg !25
+}
+
+declare dso_local void @foo1(i32*, i32) local_unnamed_addr #1
+
+declare dso_local void @foo2(i32*, i8) local_unnamed_addr #1
+
+; Function Attrs: nounwind readnone speculatable
+declare void @llvm.dbg.value(metadata, metadata, metadata) #2
+
+attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "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" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #2 = { nounwind readnone speculatable }
+attributes #3 = { nounwind }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!6, !7, !8}
+!llvm.ident = !{!9}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 7.0.0 (https://edgetools.visualstudio.com/DefaultCollection/llvm/_git/clang 142e9e9094e8bee77d678bb6d6c424d473834df8) (https://edgetools.visualstudio.com/DefaultCollection/_git/llvm e4e9c2f5cc01b02faa0070dae228ea626170f422)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3)
+!1 = !DIFile(filename: "debug_value.c", directory: "/home/sejooh/workspaces/ws0/tmp")
+!2 = !{}
+!3 = !{!4, !5}
+!4 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_unsigned_char)
+!5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!6 = !{i32 2, !"Dwarf Version", i32 4}
+!7 = !{i32 2, !"Debug Info Version", i32 3}
+!8 = !{i32 1, !"wchar_size", i32 4}
+!9 = !{!"clang version 7.0.0 (https://edgetools.visualstudio.com/DefaultCollection/llvm/_git/clang 142e9e9094e8bee77d678bb6d6c424d473834df8) (https://edgetools.visualstudio.com/DefaultCollection/_git/llvm e4e9c2f5cc01b02faa0070dae228ea626170f422)"}
+!10 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 16, type: !11, isLocal: false, isDefinition: true, scopeLine: 16, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !14)
+!11 = !DISubroutineType(types: !12)
+!12 = !{!5, !13, !5}
+!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64)
+!14 = !{!15, !16, !17}
+!15 = !DILocalVariable(name: "a", arg: 1, scope: !10, file: !1, line: 16, type: !13)
+!16 = !DILocalVariable(name: "b", arg: 2, scope: !10, file: !1, line: 16, type: !5)
+!17 = !DILocalVariable(name: "t", scope: !10, file: !1, line: 17, type: !4)
+!18 = !DILocation(line: 16, column: 14, scope: !10)
+!19 = !DILocation(line: 16, column: 21, scope: !10)
+!20 = !DILocation(line: 17, column: 11, scope: !10)
+!21 = !DILocation(line: 17, column: 7, scope: !10)
+!22 = !DILocation(line: 18, column: 10, scope: !10)
+!23 = !DILocation(line: 18, column: 2, scope: !10)
+!24 = !DILocation(line: 19, column: 2, scope: !10)
+!25 = !DILocation(line: 20, column: 1, scope: !10)
Index: test/CodeGen/ARM/debug-info-d16-reg.ll
===================================================================
--- test/CodeGen/ARM/debug-info-d16-reg.ll
+++ test/CodeGen/ARM/debug-info-d16-reg.ll
@@ -82,9 +82,9 @@
 !20 = !DILocalVariable(name: "val", line: 4, arg: 2, scope: !9, file: !1, type: !7)
 !21 = !DILocalVariable(name: "c", line: 4, arg: 3, scope: !9, file: !1, type: !8)
 
-!49 = !DILocalVariable(name: "ptr", line: 4, arg: 1, scope: !9, file: !1, type: !6)
-!50 = !DILocalVariable(name: "val", line: 4, arg: 2, scope: !9, file: !1, type: !7)
-!51 = !DILocalVariable(name: "c", line: 4, arg: 2, scope: !9, file: !1, type: !8)
+!49 = !DILocalVariable(name: "ptr", line: 4, scope: !10, file: !1, type: !6)
+!50 = !DILocalVariable(name: "val", line: 4, scope: !10, file: !1, type: !7)
+!51 = !DILocalVariable(name: "c", line: 4, scope: !10, file: !1, type: !8)
 
 !22 = !DILocalVariable(name: "argc", line: 17, arg: 1, scope: !10, file: !1, type: !5)
 !23 = !DILocalVariable(name: "argv", line: 17, arg: 2, scope: !10, file: !1, type: !13)
Index: lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
+++ lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
@@ -776,6 +776,8 @@
   SDValue &OpEntry = PromotedIntegers[Op];
   assert(!OpEntry.getNode() && "Node is already promoted!");
   OpEntry = Result;
+
+  DAG.transferDbgValues(Op, Result);
 }
 
 void DAGTypeLegalizer::SetSoftenedFloat(SDValue Op, SDValue Result) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44546.138790.patch
Type: text/x-patch
Size: 6048 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180316/374d0f48/attachment.bin>


More information about the llvm-commits mailing list