Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cached disposition of [...] is incorrect: cached Variant, actual Invariant with -verify-scev and loop-deletion #58314

Closed
mikaelholmen opened this issue Oct 12, 2022 · 2 comments
Labels
llvm:crash llvm:SCEV Scalar Evolution

Comments

@mikaelholmen
Copy link
Collaborator

mikaelholmen commented Oct 12, 2022

llvm commit:
Reproduce with:

opt -passes="indvars,loop-deletion" bbi-74655.ll -o /dev/null -verify-scev

Result:

Cached disposition of (true + %tobool2) for loop Loop at depth 2 containing: %for.cond1<header>,%if.then<exiting>,%for.cond1thread-pre-split<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 -passes=indvars,loop-deletion bbi-74655.ll -o /dev/null -verify-scev
 #0 0x0000000002e636e3 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../../main-github/llvm/build-all/bin/opt+0x2e636e3)
 #1 0x0000000002e613fe llvm::sys::RunSignalHandlers() (../../main-github/llvm/build-all/bin/opt+0x2e613fe)
 #2 0x0000000002e63a66 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007fa9b815f630 __restore_rt sigaction.c:0:0
 #4 0x00007fa9b58a6387 raise (/lib64/libc.so.6+0x36387)
 #5 0x00007fa9b58a7a78 abort (/lib64/libc.so.6+0x37a78)
 #6 0x0000000001e8f7dc llvm::ScalarEvolution::verify() const (../../main-github/llvm/build-all/bin/opt+0x1e8f7dc)
 #7 0x00000000037f1cdb llvm::FunctionToLoopPassAdaptor::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x37f1cdb)
 #8 0x00000000031ceb0d llvm::detail::PassModel<llvm::Function, llvm::FunctionToLoopPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) crtstuff.c:0:0
 #9 0x00000000026487dc llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (../../main-github/llvm/build-all/bin/opt+0x26487dc)
#10 0x0000000000ae93bd 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>&) crtstuff.c:0:0
#11 0x000000000264cabe llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x264cabe)
#12 0x0000000000ae919d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) crtstuff.c:0:0
#13 0x0000000002647a8c llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (../../main-github/llvm/build-all/bin/opt+0x2647a8c)
#14 0x000000000071ffa9 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::StringRef>, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool) (../../main-github/llvm/build-all/bin/opt+0x71ffa9)
#15 0x0000000000730751 main (../../main-github/llvm/build-all/bin/opt+0x730751)
#16 0x00007fa9b5892555 __libc_start_main (/lib64/libc.so.6+0x22555)
#17 0x0000000000718cf0 _start (../../main-github/llvm/build-all/bin/opt+0x718cf0)
Abort

bbi-74655.ll.gz

@fhahn
Copy link
Contributor

fhahn commented Oct 12, 2022

Thanks for the test case. Looks like makeLoopInvariant moves operands recursively, but we only invalidate block & loop dispositions for the original instruction. Looking into a fix.

@fhahn
Copy link
Contributor

fhahn commented Oct 13, 2022

Proposed fix: https://reviews.llvm.org/D135909

@fhahn fhahn closed this as completed in 16cf666 Oct 14, 2022
sid8123 pushed a commit to sid8123/llvm-project that referenced this issue Oct 25, 2022
makeLoopInvariant may recursively move its operands to make them
invariant, before moving the passed in instruction. Those recursively
moved instructions are currently missed when invalidating block and loop
dispositions.

To address this, move the invalidation code to Loop::makeLoopInvariant.

Fixes llvm#58314.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D135909
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm:crash llvm:SCEV Scalar Evolution
Projects
None yet
Development

No branches or pull requests

2 participants