[llvm-bugs] [Bug 49171] [LoopUnroll] compile-time explosion with assumes at -O3

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Feb 15 12:50:51 PST 2021


https://bugs.llvm.org/show_bug.cgi?id=49171

Sanjay Patel <spatel+llvm at rotateright.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|CONFIRMED                   |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Sanjay Patel <spatel+llvm at rotateright.com> ---
(In reply to Nikita Popov from comment #8)
> @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.

Thanks! Committed the quick fix here - https://reviews.llvm.org/rG378941f611ab

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210215/fb49b635/attachment-0001.html>


More information about the llvm-bugs mailing list