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

LLVM ERROR: Instruction Combining seems stuck in an infinite loop after 100 iterations. #48699

Closed
JonPsson opened this issue Feb 25, 2021 · 5 comments
Labels
bugzilla Issues migrated from bugzilla crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:instcombine

Comments

@JonPsson
Copy link
Contributor

Bugzilla Link 49355
Version trunk
OS Linux
Attachments reduced testcase
CC @JonPsson,@rotateright

Extended Description

opt -mtriple=s390x-linux-gnu -mcpu=arch13 -o out.opt.ll -S -O3 -enable-gvn-memdep=false -simplifycfg-sink-common=false -unroll-count=10 crash0_aftercreduce.bc

@rotateright
Copy link
Contributor

I'm not sure if this is the only problem, and I'm also not sure about our rules for pointer comparison, but this seems like a missing constant fold opportunity:

define i1 @​#49355 (i8* %x) {
%cmp = icmp ule i8 (...)* null, bitcast (i1 (i8*)* @​#49355 to i8 (...)*)
ret i1 %cmp
}

$ ./opt -instsimplify cmp_null_const_expr.ll -S
define i1 @​#49355 (i8* %x) {
ret i1 icmp uge (i8 (...)* bitcast (i1 (i8*)* @​#49355 to i8 (...)), i8 (...) null)
}

@rotateright
Copy link
Contributor

I'm not sure if this is the only problem, and I'm also not sure about our
rules for pointer comparison, but this seems like a missing constant fold
opportunity:

define i1 @​#49355 (i8* %x) {
%cmp = icmp ule i8 (...)* null, bitcast (i1 (i8*)* @​#49355 to i8 (...)*)
ret i1 %cmp
}

$ ./opt -instsimplify cmp_null_const_expr.ll -S
define i1 @​#49355 (i8* %x) {
ret i1 icmp uge (i8 (...)* bitcast (i1 (i8*)* @​#49355 to i8 (...)), i8
(...)
null)
}

https://reviews.llvm.org/rGf75b5305f4de

That should at least allow us to reduce the test to only "opt -instcombine". I had a machine working on bugpoint reducing that for over an hour, but it failed when I updated 'opt' while working on another bug. I'll try reducing again later.

@rotateright
Copy link
Contributor

Bugpoint was spinning away at this for 8+ hours on my machine.

The test is triggering some iterative transform - increasing the iteration limit will avoid the assert (the function will "finish" optimizing within instcombine).

We can also decrease the iteration limit to create a smaller example with bugpoint:

$ bugpoint -instcombine 49355.ll -run-llc --opt-args -instcombine-infinite-loop-threshold=8

But it doesn't look like bug 49122 and related bugs that I've diagnosed. There are no stores in the code. Something else is going on.

@rotateright
Copy link
Contributor

reduced test for instcombine
Asserts with:
$ opt 49355iter8.ll -S -instcombine -instcombine-infinite-loop-threshold=8

(but completes at iteration 9)

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@nikic
Copy link
Contributor

nikic commented Sep 26, 2023

No longer reproduces, presumably fixed by single-iteration InstCombine work.

@nikic nikic closed this as completed Sep 26, 2023
@Endilll Endilll added crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:instcombine labels Sep 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:instcombine
Projects
None yet
Development

No branches or pull requests

4 participants