<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 - "function-local metadata used in wrong function" with -argpromotion -verify -dse"
   href="https://bugs.llvm.org/show_bug.cgi?id=33641">33641</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>"function-local metadata used in wrong function" with -argpromotion -verify -dse
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>mikael.holmen@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=18732" name="attach_18732" title="reproducer">attachment 18732</a> <a href="attachment.cgi?id=18732&action=edit" title="reproducer">[details]</a></span>
reproducer

Reproduce with:
opt -argpromotion -verify -dse -S -o /dev/null reduced.ll

which gives:

function-local metadata used in wrong function
i16 addrspace(1)* %p
LLVM ERROR: Broken function found, compilation aborted!



With -print-before-all -print-after-all -debug we see

*** IR Dump Before Promote 'by reference' arguments to scalars ***
define internal void @bar(i16 addrspace(1)* %p) {
bb1:
  call void @llvm.dbg.value(metadata i16 addrspace(1)* %p, i64 0, metadata !3,
metadata !5), !dbg !6
  ret void
}
ARG PROMOTION:  Promoting to:
declare internal void @bar()

From: 
define internal void @bar(i16 addrspace(1)* %p) {
bb1:
  call void @llvm.dbg.value(metadata i16 addrspace(1)* %p, i64 0, metadata !3,
metadata !5), !dbg !6
  ret void
}
CGSCCPASSMGR: Refreshing SCC with 1 nodes:
Call graph node for function: 'bar'<<0x5116db0>>  #uses=0

CGSCCPASSMGR: SCC Refresh didn't change call graph.
*** IR Dump After Promote 'by reference' arguments to scalars ***
define internal void @bar() {
bb1:
  call void @llvm.dbg.value(metadata i16 addrspace(1)* %p, i64 0, metadata !3,
metadata !5), !dbg !6
  ret void
}

So the %p argument to bar has been removed, but the call to @llvm.dbg.value
which uses %p is still left.

Since ArgumentPromotion changes the argument list by creating a new function
with the desired argument list, we then get the error about using meta data
from the wrong function.</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>