<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [DebugInfo] Undef DBG_VALUE is emitted for float parameter passed on the stack"
   href="https://bugs.llvm.org/show_bug.cgi?id=40777">40777</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[DebugInfo] Undef DBG_VALUE is emitted for float parameter passed on the stack
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>DebugInfo
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>david.stenberg@ericsson.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>jdevlieghere@apple.com, keith.walker@arm.com, llvm-bugs@lists.llvm.org, paul_robinson@playstation.sony.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>On r353941, if you compile the following code with `--target=arm -O1 -g':

    float fn1(int p1, int p2, int p3, int p4, float p5) {
      return p5;
    }

no non-undef location is emitted for p5:

    fn1:
    .Lfunc_begin0:
            .file   1 "/path/to/repo" "float.c"
            .loc    1 1 0                   @ float.c:1:0
            .fnstart
            .cfi_sections .debug_frame
            .cfi_startproc
    @ %bb.0:                                @ %entry
            @DEBUG_VALUE: fn1:p1 <- $r0
            @DEBUG_VALUE: fn1:p2 <- $r1
            @DEBUG_VALUE: fn1:p3 <- $r2
            @DEBUG_VALUE: fn1:p4 <- $r3
            ldr     r0, [sp]
    .Ltmp0:
            @DEBUG_VALUE: fn1:p5 <- undef <------------------------

llvm-dwarfdump output: 

    0x00000071:     DW_TAG_formal_parameter
                      DW_AT_name    ("p5")
                      DW_AT_decl_file       ("/path/to/repo/float.c")
                      DW_AT_decl_line       (1)
                      DW_AT_type    (0x0000007d "float")

llc -debug output:

    *** IR Dump After Module Verifier ***
    ; Function Attrs: norecurse nounwind readnone
    define dso_local arm_aapcscc float @fn1(i32 %p1, i32 %p2, i32 %p3, i32 %p4,
float returned %p5) local_unnamed_addr #0 !dbg !8 {
    entry:
      call void @llvm.dbg.value(metadata i32 %p1, metadata !14, metadata
!DIExpression()), !dbg !19
      call void @llvm.dbg.value(metadata i32 %p2, metadata !15, metadata
!DIExpression()), !dbg !20
      call void @llvm.dbg.value(metadata i32 %p3, metadata !16, metadata
!DIExpression()), !dbg !21
      call void @llvm.dbg.value(metadata i32 %p4, metadata !17, metadata
!DIExpression()), !dbg !22
      call void @llvm.dbg.value(metadata float %p5, metadata !18, metadata
!DIExpression()), !dbg !23
      ret float %p5, !dbg !24
    }
    # *** IR Dump Before ARM Instruction Selection ***:
    # Machine code for function fn1: IsSSA, TracksLiveness

    # End machine code for function fn1.

    # *** IR Dump After ARM Instruction Selection ***:
    # Machine code for function fn1: IsSSA, TracksLiveness
    Frame Objects:
      fi#-1: size=4, align=8, fixed, at location [SP]

    bb.0.entry:
      DBG_VALUE $r0, $noreg, !"p1", !DIExpression(), debug-location !19;
float.c:1:15 line no:1
      DBG_VALUE $r1, $noreg, !"p2", !DIExpression(), debug-location !20;
float.c:1:23 line no:1
      DBG_VALUE $r2, $noreg, !"p3", !DIExpression(), debug-location !21;
float.c:1:31 line no:1
      DBG_VALUE $r3, $noreg, !"p4", !DIExpression(), debug-location !22;
float.c:1:39 line no:1
      %4:gpr = LDRi12 %fixed-stack.0, 0, 14, $noreg :: (load 4 from
%fixed-stack.0, align 8)
      DBG_VALUE $noreg, $noreg, !"p5", !DIExpression(), debug-location !23;
float.c:1:49 line no:1
      $r0 = COPY %4:gpr, debug-location !24; float.c:2:3
      BX_RET 14, $noreg, implicit $r0, debug-location !24; float.c:2:3

    # End machine code for function fn1.

If you instead change p5 to an int, a FI-referencing debug value is inserted
for the parameter at the start of the function. That DBG_VALUE is produced by
the following code in EmitFuncArgumentDbgValue():

      if (!Op && N.getNode())
        // Check if frame index is available.
        if (LoadSDNode *LNode = dyn_cast<LoadSDNode>(N.getNode()))
          if (FrameIndexSDNode *FINode =
              dyn_cast<FrameIndexSDNode>(LNode->getBasePtr().getNode()))
            Op = MachineOperand::CreateFI(FINode->getIndex());

However, in the case of the float parameter, the LoadSDNode is wrapped by a
bitcast, resulting in that code not triggering.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>