<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><span class="vcard"><a class="email" href="mailto:spatel+llvm@rotateright.com" title="Sanjay Patel <spatel+llvm@rotateright.com>"> <span class="fn">Sanjay Patel</span></a>
</span> changed
          <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - [LoopUnroll] compile-time explosion with assumes at -O3"
   href="https://bugs.llvm.org/show_bug.cgi?id=49171">bug 49171</a>
          <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Status</td>
           <td>CONFIRMED
           </td>
           <td>RESOLVED
           </td>
         </tr>

         <tr>
           <td style="text-align:right;">Resolution</td>
           <td>---
           </td>
           <td>FIXED
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - [LoopUnroll] compile-time explosion with assumes at -O3"
   href="https://bugs.llvm.org/show_bug.cgi?id=49171#c9">Comment # 9</a>
              on <a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - [LoopUnroll] compile-time explosion with assumes at -O3"
   href="https://bugs.llvm.org/show_bug.cgi?id=49171">bug 49171</a>
              from <span class="vcard"><a class="email" href="mailto:spatel+llvm@rotateright.com" title="Sanjay Patel <spatel+llvm@rotateright.com>"> <span class="fn">Sanjay Patel</span></a>
</span></b>
        <pre>(In reply to Nikita Popov from <a href="show_bug.cgi?id=49171#c8">comment #8</a>)
<span class="quote">> @spatel Your patch with a limit of 15 looks fine to me. I don't think we
> need to do further experiments, as this is a question of worst-case
> complexity rather than average-case performance.</span >

Thanks! Committed the quick fix here - <a href="https://reviews.llvm.org/rG378941f611ab">https://reviews.llvm.org/rG378941f611ab</a>

I think that's enough to say this bug is fixed, but reopen if I got that wrong.

I haven't been following the details of guaranteed progress discussions, so not
sure how to test this...does this correctly implement the suggested check for
function attributes?

diff --git a/llvm/lib/Analysis/ValueTracking.cpp
b/llvm/lib/Analysis/ValueTracking.cpp
index 493eb08bb9b0..ef78847cb43e 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -548,6 +548,12 @@ bool llvm::isValidAssumeForContext(const Instruction *Inv,
     if (Inv == CxtI)
       return false;

+    // Use function attributes to check if execution must reach the assume.
+    const Function *F = CxtI->getFunction();
+    if (F->hasFnAttribute(Attribute::WillReturn) ||
+        F->hasFnAttribute(Attribute::NoUnwind))
+      return !isEphemeralValueOf(Inv, CxtI);
+
     // The context comes first, but they're both in the same block.
     // Make sure there is nothing in between that might interrupt
     // the control flow, not even CxtI itself.</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>