<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 - 'Undefined behavior: Call with "tail" keyword references alloca' after memcpyopt"
   href="https://bugs.llvm.org/show_bug.cgi?id=35241">35241</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>'Undefined behavior: Call with "tail" keyword references alloca' after memcpyopt
          </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=19382" name="attach_19382" title="reproducer">attachment 19382</a> <a href="attachment.cgi?id=19382&action=edit" title="reproducer">[details]</a></span>
reproducer

opt -memcpyopt -lint -S -o tr14894.opt.ll tr14894.ll

makes lint complain with

Undefined behavior: Call with "tail" keyword references alloca
  tail call void @f1(%s* byval align 1 %c)

memcpyopt has turned

%tmp1 = bitcast %s* %c to i8*
%tmp2 = bitcast i8* bitcast (%s* @b to i8*) to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp2, i8* %tmp1, i32 3, i32 1, i1
false)
tail call void @f1(%s* byval align 1 @b)

into

%tmp1 = bitcast %s* %c to i8*
%tmp2 = bitcast i8* getelementptr inbounds (%s, %s* @b, i32 0, i32 0) to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp2, i8* %tmp1, i32 3, i32 1, i1
false)
tail call void @f1(%s* byval align 1 %c)

Should memcpyopt avoid th transformation for tail calls perhaps?

(Or is the lint warning in fact wrong for byval arguments?)</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>