summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2018-01-11 18:35:12 +0000
committerAdrian Prantl <aprantl@apple.com>2018-01-11 18:35:12 +0000
commit29102b30023991ec1f15af5fd371d9504ed24ad5 (patch)
tree3c2cb0f479358de23a3f0b6984eb2732b2b42fc6
parent240df6faa4f6f8ea13b3006f2808b64b6d647b02 (diff)
downloadbcm5719-llvm-29102b30023991ec1f15af5fd371d9504ed24ad5.tar.gz
bcm5719-llvm-29102b30023991ec1f15af5fd371d9504ed24ad5.zip
dag-combine: Transfer debug information when folding (zext (truncate x))
-> (zext (truncate x)) This patch adds debug info support to the dagcombine rule (zext (truncate x)) -> (zext (truncate x)). Differential Revision: https://reviews.llvm.org/D41924 llvm-svn: 322304
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp5
-rw-r--r--llvm/test/DebugInfo/X86/sdag-combine.ll46
2 files changed, 50 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 4ae22d69eaf..093a20057c6 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -7800,7 +7800,10 @@ SDValue DAGCombiner::visitZERO_EXTEND(SDNode *N) {
SDValue Op = N0.getOperand(0);
Op = DAG.getZeroExtendInReg(Op, SDLoc(N), MinVT.getScalarType());
AddToWorklist(Op.getNode());
- return DAG.getZExtOrTrunc(Op, SDLoc(N), VT);
+ SDValue ZExtOrTrunc = DAG.getZExtOrTrunc(Op, SDLoc(N), VT);
+ // Transfer the debug info; the new node is equivalent to N0.
+ DAG.transferDbgValues(N0, ZExtOrTrunc);
+ return ZExtOrTrunc;
}
}
diff --git a/llvm/test/DebugInfo/X86/sdag-combine.ll b/llvm/test/DebugInfo/X86/sdag-combine.ll
new file mode 100644
index 00000000000..0fb809e2abb
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/sdag-combine.ll
@@ -0,0 +1,46 @@
+; RUN: llc %s -stop-after=livedebugvars -o - | FileCheck %s
+source_filename = "/tmp/t.ll"
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.13"
+
+%TSb = type <{ i1 }>
+
+declare swiftcc i1 @f()
+
+; Function Attrs: nounwind readnone speculatable
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
+
+; Function Attrs: nounwind readnone speculatable
+define swiftcc void @g() #0 !dbg !5 {
+entry:
+ %0 = alloca %TSb, align 1
+ %1 = call swiftcc i1 @f(), !dbg !7
+ ; CHECK: DBG_VALUE debug-use %rax, debug-use %noreg, !8, !DIExpression(), debug-location !7
+ call void @llvm.dbg.value(metadata i1 %1, metadata !8, metadata !DIExpression()), !dbg !7
+ %2 = getelementptr inbounds %TSb, %TSb* %0, i32 0, i32 0, !dbg !7
+ store i1 %1, i1* %2, align 1, !dbg !7
+ %3 = zext i1 %1 to i64, !dbg !7
+ call void asm sideeffect "", "r"(i64 %3), !dbg !7
+ ret void, !dbg !7
+}
+
+; Function Attrs: nounwind readnone speculatable
+declare void @llvm.dbg.value(metadata, metadata, metadata) #0
+
+attributes #0 = { nounwind readnone speculatable }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_Swift, file: !1, isOptimized: false, runtimeVersion: 4, emissionKind: FullDebug, enums: !2, imports: !2)
+!1 = !DIFile(filename: "t.swift", directory: "/tmp")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = distinct !DISubprogram(name: "g", scope: !0, file: !1, line: 2, type: !6, isLocal: false, isDefinition: true, scopeLine: 2, isOptimized: false, unit: !0, variables: !2)
+!6 = !DISubroutineType(types: !2)
+!7 = !DILocation(line: 4, scope: !5)
+!8 = !DILocalVariable(name: "hasInput", scope: !5, file: !1, line: 3, type: !9)
+!9 = !DICompositeType(tag: DW_TAG_structure_type, name: "Bool", scope: !11, file: !10, size: 8, elements: !2, runtimeLang: DW_LANG_Swift, identifier: "_T0SbD")
+!10 = !DIFile(filename: "Swift.swiftmodule", directory: "/usr/lib/swift/macosx/x86_64")
+!11 = !DIModule(scope: null, name: "Swift", includePath: "/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk")
OpenPOWER on IntegriCloud