[llvm] r318086 - Fix an assertion in SelectionDAG::transferDbgValues()
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 13 13:24:54 PST 2017
Author: adrian
Date: Mon Nov 13 13:24:54 2017
New Revision: 318086
URL: http://llvm.org/viewvc/llvm-project?rev=318086&view=rev
Log:
Fix an assertion in SelectionDAG::transferDbgValues()
when transferring debug info describing the lower bits of an extended SDNode.
rdar://problem/35504722
Added:
llvm/trunk/test/DebugInfo/ARM/sdag-split-arg1.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=318086&r1=318085&r2=318086&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Nov 13 13:24:54 2017
@@ -7042,18 +7042,23 @@ void SelectionDAG::transferDbgValues(SDV
auto *Expr = Dbg->getExpression();
// If a fragment is requested, update the expression.
if (SizeInBits) {
- auto Fragment = DIExpression::createFragmentExpression(
- Dbg->getExpression(), OffsetInBits, SizeInBits);
- if (Fragment)
- Expr = *Fragment;
- }
- // Clone the SbgValue unless the fragment creation failed.
- if (!SizeInBits || (SizeInBits && Expr)) {
- SDDbgValue *Clone =
- getDbgValue(Var, Expr, ToNode, To.getResNo(), Dbg->isIndirect(),
- Dbg->getDebugLoc(), Dbg->getOrder());
- ClonedDVs.push_back(Clone);
+ // When splitting a larger (e.g., sign-extended) value whose
+ // lower bits are described with an SDDbgValue, do not attempt
+ // to transfer the SDDbgValue to the upper bits.
+ if (auto FI = Expr->getFragmentInfo())
+ if (OffsetInBits + SizeInBits > FI->SizeInBits)
+ continue;
+ auto Fragment = DIExpression::createFragmentExpression(Expr, OffsetInBits,
+ SizeInBits);
+ if (!Fragment)
+ continue;
+ Expr = *Fragment;
}
+ // Clone the SDDbgValue and move it to To.
+ SDDbgValue *Clone =
+ getDbgValue(Var, Expr, ToNode, To.getResNo(), Dbg->isIndirect(),
+ Dbg->getDebugLoc(), Dbg->getOrder());
+ ClonedDVs.push_back(Clone);
Dbg->setIsInvalidated();
}
Added: llvm/trunk/test/DebugInfo/ARM/sdag-split-arg1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/ARM/sdag-split-arg1.ll?rev=318086&view=auto
==============================================================================
--- llvm/trunk/test/DebugInfo/ARM/sdag-split-arg1.ll (added)
+++ llvm/trunk/test/DebugInfo/ARM/sdag-split-arg1.ll Mon Nov 13 13:24:54 2017
@@ -0,0 +1,28 @@
+; RUN: llc -filetype=asm %s -o - -stop-after=livedebugvalues | FileCheck %s
+; This tests that transferring debug info describing the lower bits of
+; an extended SDNode works.
+target triple = "thumbv6m-apple-unknown-macho"
+define arm_aapcscc i64 @f(double %a) !dbg !5 {
+entry:
+ %0 = bitcast double %a to i64
+ %extract.t84 = trunc i64 %0 to i32
+ tail call void @llvm.dbg.value(metadata i32 %extract.t84, metadata !8, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg !12
+ ; CHECK: DBG_VALUE debug-use %r0, debug-use _, !6, !DIExpression(DW_OP_LLVM_fragment, 0, 32)
+ %r.sroa.0.0.insert.ext35 = zext i32 %extract.t84 to i64
+ ret i64 %r.sroa.0.0.insert.ext35
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "LLVM", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2)
+!1 = !DIFile(filename: "f.c", directory: "/")
+!2 = !{}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 29, type: !7, isLocal: false, isDefinition: true, scopeLine: 30, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !2)
+!7 = !DISubroutineType(types: !2)
+!8 = !DILocalVariable(name: "r", scope: !5, file: !1, line: 37, type: !11)
+!11 = distinct !DICompositeType(tag: DW_TAG_union_type, file: !1, line: 33, size: 64, elements: !2)
+!12 = !DILocation(line: 37, column: 12, scope: !5)
More information about the llvm-commits
mailing list