<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 - VirtualBox miscompiled after LLVM r345163 / 18bfb3a5ec41"
   href="https://bugs.llvm.org/show_bug.cgi?id=45334">45334</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>VirtualBox miscompiled after LLVM r345163 / 18bfb3a5ec41
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>FreeBSD
          </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>kevans@FreeBSD.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>After r345163 ("[CodeGen] skip lifetime end marker in isInTailCallPosition"),
LLVM 8.0+ no longer compile VirtualBox 5.2.x correctly -- notably, new machines
result in failure/segfault.

Both reverting this commit (see diff at the end of this e-mail) and building a
Debug build (so no more -O2) fix the observed behavior.

I'm still trying to work out where the problem's actually happening so that I
can produce a minimal reproducer... the code involved in the problematic area
(New VM wizard -> actual machine creation) is a twisty maze of C++ with various
bits like local variables that manage an object and then set a pointer in their
dtor and other fun lifetime-related tricks.

--- lib/CodeGen/Analysis.cpp.orig       2020-03-26 15:48:08 UTC
+++ lib/CodeGen/Analysis.cpp
@@ -538,11 +538,10 @@ bool llvm::isInTailCallPosition(ImmutableCallSite CS, 
       // Debug info intrinsics do not get in the way of tail call
optimization.
       if (isa<DbgInfoIntrinsic>(BBI))
         continue;
-      // A lifetime end or assume intrinsic should not stop tail call
+      // An assume intrinsic should not stop tail call
       // optimization.
       if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(BBI))
-        if (II->getIntrinsicID() == Intrinsic::lifetime_end ||
-            II->getIntrinsicID() == Intrinsic::assume)
+        if (II->getIntrinsicID() == Intrinsic::assume)
           continue;
       if (BBI->mayHaveSideEffects() || BBI->mayReadFromMemory() ||
           !isSafeToSpeculativelyExecute(&*BBI))</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>