From: David Stenberg Date: Mon, 18 Mar 2019 11:27:32 +0000 (+0000) Subject: [DebugInfo] Ignore bitcasts when lowering stack arg dbg.values X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=95c6236239db8f68a4ac166e9129f16a26bac27d;p=llvm [DebugInfo] Ignore bitcasts when lowering stack arg dbg.values Summary: Look past bitcasts when looking for parameter debug values that are described by frame-index loads in `EmitFuncArgumentDbgValue()`. In the attached test case we would be left with an undef `DBG_VALUE` for the parameter without this patch. A similar fix was done for parameters passed in registers in D13005. This fixes PR40777. Reviewers: aprantl, vsk, jmorse Reviewed By: aprantl Subscribers: bjope, javed.absar, jdoerfert, llvm-commits Tags: #debug-info, #llvm Differential Revision: https://reviews.llvm.org/D58831 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356363 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 6a88948ac6b..fb57f5dd2c5 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -5326,12 +5326,14 @@ bool SelectionDAGBuilder::EmitFuncArgumentDbgValue( } } - if (!Op && N.getNode()) + if (!Op && N.getNode()) { // Check if frame index is available. - if (LoadSDNode *LNode = dyn_cast(N.getNode())) + SDValue LCandidate = peekThroughBitcasts(N); + if (LoadSDNode *LNode = dyn_cast(LCandidate.getNode())) if (FrameIndexSDNode *FINode = dyn_cast(LNode->getBasePtr().getNode())) Op = MachineOperand::CreateFI(FINode->getIndex()); + } if (!Op) { // Check if ValueMap has reg number. diff --git a/test/DebugInfo/ARM/float-stack-arg.ll b/test/DebugInfo/ARM/float-stack-arg.ll new file mode 100644 index 00000000000..d5cce276700 --- /dev/null +++ b/test/DebugInfo/ARM/float-stack-arg.ll @@ -0,0 +1,53 @@ +; RUN: llc -mtriple=armv4t-unknown-unknown -start-after=codegenprepare -stop-before=expand-isel-pseudos -o - %s | FileCheck %s + +; Verify that a stack-referencing DBG_VALUE is emitted for p5 at the start of +; the function. +; +; Reproducer for PR40777. +; +; Based on the following C reproducer: +; +; float fn1(int p1, int p2, int p3, int p4, float p5) { +; return p5; +; } +; +; that was compiled using -O1 -g -S -emit-llvm. +; +; Irrelevant metadata, e.g. information about %p[1-4], has been stripped. + +; CHECK: ![[P5:[0-9]*]] = !DILocalVariable(name: "p5" + +define arm_aapcscc float @fn1(i32 %p1, i32 %p2, i32 %p3, i32 %p4, float returned %p5) #0 !dbg !7 { +; CHECK-LABEL: bb.0.entry: +; CHECK-NEXT: DBG_VALUE %fixed-stack.0, 0, ![[P5]] +entry: + call void @llvm.dbg.value(metadata float %p5, metadata !17, metadata !DIExpression()), !dbg !18 + ret float %p5, !dbg !19 +} + +; Function Attrs: nounwind readnone speculatable +declare void @llvm.dbg.value(metadata, metadata, metadata) #1 + +attributes #0 = { norecurse nounwind readnone } +attributes #1 = { nounwind readnone speculatable } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5} +!llvm.ident = !{!6} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None) +!1 = !DIFile(filename: "float.c", directory: "/") +!2 = !{} +!3 = !{i32 2, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"min_enum_size", i32 4} +!6 = !{!"clang version 9.0.0"} +!7 = distinct !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !12) +!8 = !DISubroutineType(types: !9) +!9 = !{!10, !11, !11, !11, !11, !10} +!10 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float) +!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!12 = !{!17} +!17 = !DILocalVariable(name: "p5", arg: 5, scope: !7, file: !1, line: 1, type: !10) +!18 = !DILocation(line: 1, scope: !7) +!19 = !DILocation(line: 2, scope: !7)