<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - SROA is dropping !nonnull/!range metadata"
   href="https://llvm.org/bugs/show_bug.cgi?id=31142">31142</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SROA is dropping !nonnull/!range metadata
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.9
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>arielb1@mail.tau.ac.il
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When SROA optimizes out an alloca whose load contains a !nonnull metadata, the
load is dropped on the floor.

This can lead to the metadata being dropped in cases such as

    define float* @yummy_nonnull(float**) {
    entry-block:
      %buf = alloca float*

      %_0_i8 = bitcast float** %0 to i8*
      %_buf_i8 = bitcast float** %buf to i8*
      call void @llvm.memcpy.p0i8.p0i8.i64(i8* %_buf_i8, i8* %_0_i8, i64 8, i32
8, i1 false)

      %ret = load float*, float** %buf, align 8, !nonnull !0
      ret float* %ret
    }

    declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8*
nocapture readonly, i64, i32, i1)
    !0 = !{}

Which is optimized to
    define float* @yummy_nonnull(float** nocapture readonly) local_unnamed_addr
#0 {
    entry-block:
      %buf.0.copyload = load float*, float** %0, align 8
      ret float* %buf.0.copyload
    }


If this function is later inlined, the !nonnull metadata will no longer be
present to help further optimizations.

This is the cause of Rust bug <a href="https://github.com/rust-lang/rust/issues/37945">https://github.com/rust-lang/rust/issues/37945</a>.</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>