<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 - Too much narrowing when converting dbg.declare to dbg.value"
   href="https://bugs.llvm.org/show_bug.cgi?id=35400">35400</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Too much narrowing when converting dbg.declare to dbg.value
          </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>mattias.v.eriksson@ericsson.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19462" name="attach_19462" title="Reproduce with: opt -sroa -S dbgvaluesext.ll">attachment 19462</a> <a href="attachment.cgi?id=19462&action=edit" title="Reproduce with: opt -sroa -S dbgvaluesext.ll">[details]</a></span>
Reproduce with: opt -sroa -S dbgvaluesext.ll

I think this is a bug in how a llvm.dbg.declare is converted to llvm.dbg.value.

Input, the variable "bl" is 64 bit on the stack:
define i64 @refAddshSat(i32 %param32) {
bb2:
  %local64 = alloca i64
  call void @llvm.dbg.declare(metadata i64* %local64, metadata !10, metadata
!DIExpression()), !dbg !12
  %_tmp20 = sext i32 %param32 to i64
  store i64 %_tmp20, i64* %local64
  %_tmp24 = load i64, i64* %local64
  ret i64 %_tmp24
}
!10 = !DILocalVariable(name: "bl", scope: !9, line: 58, type: !11)
!11 = !DIBasicType(name: "long long", size: 64, encoding: DW_ATE_signed)


After SROA we get "bl" as a 32 bit temporary, this looks incorrect to me:
define i64 @refAddshSat(i32 %param32) {
bb2:
  %_tmp20 = sext i32 %param32 to i64
  call void @llvm.dbg.value(metadata i32 %param32, metadata !4, metadata
!DIExpression()), !dbg !11
  ret i64 %_tmp20
}
!4 = !DILocalVariable(name: "bl", scope: !5, line: 58, type: !10)
!10 = !DIBasicType(name: "long long", size: 64, encoding: DW_ATE_signed)</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>