<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/68182>68182</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Cached disposition of [...] is incorrect: cached Variant, actual Invariant with opt -verify-scev -passes="loop-mssa(licm<allowspeculation>),loop(indvars),loop(loop-reroll)"
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mikaelholmen
</td>
</tr>
</table>
<pre>
llvm commit: 7e856d18943f
Reproduce with:
```opt -verify-scev -passes="loop-mssa(licm<allowspeculation>),loop(indvars),loop(loop-reroll)" bbi-86995.ll -o /dev/null ```
[bbi-86995.ll.gz](https://github.com/llvm/llvm-project/files/12799863/bbi-86995.ll.gz)
Result:
```
Cached disposition of %0 for loop Loop at depth 1 containing: %for.cond<header>,%lor.lhs.false<exiting>,%crit_edge,%for.body,%if.then,%for.cond.backedge<latch>
is incorrect: cached Variant, actual Invariant
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: ../../main-github/llvm/build-all/bin/opt -verify-scev -passes=loop-mssa(licm<allowspeculation>),loop(indvars),loop(loop-reroll) bbi-86995.ll -o /dev/null
#0 0x00005561addb4477 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../main-github/llvm/build-all/bin/opt+0x2f24477)
#1 0x00005561addb1fce llvm::sys::RunSignalHandlers() (../../main-github/llvm/build-all/bin/opt+0x2f21fce)
#2 0x00005561addb4b3f SignalHandler(int) (../../main-github/llvm/build-all/bin/opt+0x2f24b3f)
#3 0x00007f4f3cbf5630 __restore_rt (/lib64/libpthread.so.0+0xf630)
#4 0x00007f4f3a33c387 raise (/lib64/libc.so.6+0x36387)
#5 0x00007f4f3a33da78 abort (/lib64/libc.so.6+0x37a78)
#6 0x00005561acf8fc17 llvm::ScalarEvolution::verify() const (../../main-github/llvm/build-all/bin/opt+0x20ffc17)
#7 0x00005561ae91a146 llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x3a8a146)
#8 0x00005561adfd5a6d llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x3145a6d)
#9 0x00005561ad7d64d4 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x29464d4)
#10 0x00005561abbb37dd llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function> >, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0xd237dd)
#11 0x00005561ad7da8be llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x294a8be)
#12 0x00005561abbb357d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0xd2357d)
#13 0x00005561ad7d5664 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x2945664)
#14 0x00005561ab7b8e33 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (../../main-github/llvm/build-all/bin/opt+0x928e33)
#15 0x00005561ab7c6309 main (../../main-github/llvm/build-all/bin/opt+0x936309)
#16 0x00007f4f3a328555 __libc_start_main (/lib64/libc.so.6+0x22555)
#17 0x00005561ab7b2fd0 _start (../../main-github/llvm/build-all/bin/opt+0x922fd0)
Abort (core dumped)
```
This starts happening with 19ad1cd5cea1
```
Recommit "[SCEV] Support clearing Block/LoopDispositions for a single value."
This reverts commit 92f698f01fa0bb8967233a6391ada2d51849fa68.
The updated version of the patch includes handling for non-SCEVable
types. A test case has been added in ec86e9a99bca802.
```
which is a recommit of 9e931439ddb9
```
[SCEV] Support clearing Block/LoopDispositions for a single value.
Extend forgetBlockAndLoopDisposition to allow clearing information for a
single value. This can be useful when only a single value is changed,
e.g. because the instruction is moved.
We also need to clear the cached values for all SCEV users, because they
may depend on the starting value's disposition.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D134614
```
I guess that patch "introduces" the problem since it is more exact in that it clears a single value,
not all of SCEV as it did before. And suddenly it is exposed that someone else isn't invalidating as it should.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWV1v2zoS_TXMyyCCRH1YesiD49TYYm-xRVPcfQxG5MjiliYFknKa_fULSk5iuW739rYXdz-AwI5F8syZM4e0NEbv1c4Q3bDylpV3VziG3rqbvfqEpHur92SuWiufbrQ-7EHY_V4Flq9hRXVZyaxuirxj6R1L1x9ocFaOguBRhZ7l6_kyq9L5zw4Brg_kVPd07QUd4HpA78mz_I5xrq0drvfeI-O1VmLP8g1qbR_9QGLUGJQ1LH_DeMP4Js5lvFZGHtD5xbUJxpGzWk_XObStuq6rpikTreHaAuNbSQfGt2bUGl7YHcmWt6fzk90_WXnHeN2HMPiYEt8yvt2p0I9tIuye8W3U5fh2PTj7DxKB8W2nNHnGtxlfNU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