<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 - [missed optimization] LLVM leaves behind no-op lifetime.end cleanup"
   href="https://bugs.llvm.org/show_bug.cgi?id=45296">45296</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[missed optimization] LLVM leaves behind no-op lifetime.end cleanup
          </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>All
          </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>Transformation Utilities
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>rnk@google.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Seems related to issue 44329

Consider:

$ cat t.cpp
struct NoopDtor { ~NoopDtor() {} };
void mayThrow(NoopDtor *);
void hasCleanup() {
  NoopDtor o;
  mayThrow(&o);
}

$ clang -S -O2 t.cpp  -emit-llvm -o - | grep -A3 -E 'invoke|landingpad'
  invoke void @_Z8mayThrowP8NoopDtor(%struct.NoopDtor* nonnull %o)
          to label %invoke.cont unwind label %lpad

invoke.cont:                                      ; preds = %entry
  call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull %0) #3
  ret void

--
  %1 = landingpad { i8*, i32 }
          cleanup
  call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull %0) #3
  resume { i8*, i32 } %1

In this example, SROA is unable to remove the alloca for `o`, so the
lifetime.end remains in the landingpad cleanup. If we do not escape `o`, some
mid-level pass can remove the landingpad (I'm guessing PruneEH). We should
teach this pass to look past lifetime.end, and other meta instructions (assume,
etc).</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>