LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 36032 - After r313012, Assertion failed: (ExitCount != SE.getCouldNotCompute() && "Invalid loop count"), function generateOverflowCheck, file lib/Analysis/ScalarEvolutionExpander.cpp, line 2126.
Summary: After r313012, Assertion failed: (ExitCount != SE.getCouldNotCompute() && "In...
Status: RESOLVED FIXED
Alias: None
Product: new-bugs
Classification: Unclassified
Component: new bugs (show other bugs)
Version: trunk
Hardware: PC All
: P release blocker
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks: release-6.0
  Show dependency tree
 
Reported: 2018-01-21 12:54 PST by Dimitry Andric
Modified: 2018-02-26 16:26 PST (History)
9 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dimitry Andric 2018-01-21 12:54:30 PST
As reported in https://bugs.freebsd.org/225345, building the FreeBSD games/scummvm port for AArch64 with clang 6.0.0 results in an assertion:

Assertion failed: (ExitCount != SE.getCouldNotCompute() && "Invalid loop count"), function generateOverflowCheck, file /usr/local/poudriere/jails/head-arm64/usr/src/contrib/llvm/lib/Analysis/ScalarEvolutionExpander.cpp, line 2152.

This assertion still occurs with trunk r322755, and bisection shows it has regressed with https://reviews.llvm.org/rL313012 ("[LAA] Allow more run-time alias checks by coercing pointer expressions to AddRecExprs") by Silviu Baranga.

Minimized test case:

// clang -cc1 -triple aarch64-- -S -O1 -vectorize-loops graphics-minimized.cpp
struct {
  void *a();
} b;
char c[6];
void d() {
  unsigned char *e = (unsigned char *)b.a();
  unsigned short f;
  for (;;) {
    for (unsigned g; g < 4; g++)
      e[g] = c[g + f];
    f += 4;
  }
}

Note that -vectorize-loops is essential for reproducing the assertion.
Comment 1 Silviu Baranga 2018-01-22 04:28:28 PST
This uncovers an issue introduced in r308299.

createAddRecFromPHIWithCasts shouldn't create predicates for the loop that isn't currently processed by the SCEV rewriter because we don't have a guarantee that we have the backedge taken count.

@Dorit: could you have a look please?
Comment 2 Evgeny Stupachenko 2018-01-26 15:01:00 PST
The patch should fix the issue: https://reviews.llvm.org/D42604
Comment 3 Hans Wennborg 2018-02-19 07:39:52 PST
(In reply to Evgeny Stupachenko from comment #2)
> The patch should fix the issue: https://reviews.llvm.org/D42604

Evgeny, it looks like the patch is stuck?
Comment 4 Hans Wennborg 2018-02-21 05:08:12 PST
(In reply to Hans Wennborg from comment #3)
> (In reply to Evgeny Stupachenko from comment #2)
> > The patch should fix the issue: https://reviews.llvm.org/D42604
> 
> Evgeny, it looks like the patch is stuck?

Evgeny, Silviu: it looks like the patch is ready to be committed? This needs to land soon to be able to go into the release.
Comment 5 Silviu Baranga 2018-02-21 05:16:19 PST
Yes, I think the patch should be ready to commit, but Evgeny seems unresponsive at the moment.
Comment 6 Silviu Baranga 2018-02-21 05:58:52 PST
Ok, I'll turn off versioning for this case so that we can get the fix in time.
Comment 7 Silviu Baranga 2018-02-21 07:22:16 PST
I've disabled the buggy feature in r325687 until we can get Evgeny's fix in.
Comment 8 Hans Wennborg 2018-02-22 03:02:36 PST
(In reply to Silviu Baranga from comment #7)
> I've disabled the buggy feature in r325687 until we can get Evgeny's fix in.

Should we merge that, or what's the story for 6.0.0?
Comment 9 Silviu Baranga 2018-02-22 04:11:22 PST
Yes, let's merge r325687 for 6.0.0.
Comment 10 Hans Wennborg 2018-02-22 04:53:47 PST
(In reply to Silviu Baranga from comment #9)
> Yes, let's merge r325687 for 6.0.0.

Merged in r325773. Thanks!
Comment 11 Eric Garcia 2018-02-22 11:08:30 PST
(In reply to Silviu Baranga from comment #7)
> I've disabled the buggy feature in r325687 until we can get Evgeny's fix in.


@Silviu,

Evgeny is out of the office this week. He should be returning on Feb-26. I'll ask him to commit his fix when he returns.

Thanks,
-Eric
Comment 12 Silviu Baranga 2018-02-23 00:50:30 PST
Sure, no problem. r325687 should also be reverted once the fix goes in.

-Silviu


(In reply to Eric Garcia from comment #11)
> (In reply to Silviu Baranga from comment #7)
> > I've disabled the buggy feature in r325687 until we can get Evgeny's fix in.
> 
> 
> @Silviu,
> 
> Evgeny is out of the office this week. He should be returning on Feb-26.
> I'll ask him to commit his fix when he returns.
> 
> Thanks,
> -Eric
Comment 13 Evgeny Stupachenko 2018-02-26 16:26:39 PST
Committed to trunk revision 326154.