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 unrolls loops fully, leading to non-linear compilation time #74384
Comments
It seems #[derive(Copy, Clone)]
pub enum Foo {
A,
B(u8),
}
pub fn foo() -> [[[Foo; 50]; 50]; 50] {
[[[Foo::A; 50]; 50]; 50]
} When its nesting is a double, it will be terminated in seconds. But when it's a triple, it hangs. This doesn't seem to be technically infinite, but I would label it as |
@estebank I think this is worth a nomination as you have done, but I'm interested in hearing from you what's the reason for the nomination. What's exactly what you wanted to discuss during the meeting about this issue?. |
@spastorino wanted to flag it for prioritizing and assignment. |
Assigning We can remove |
This was reconsidered, per @Mark-Simulacrum's comments and we consider now Anyway, given that we checked this issue slightly during our last meeting, I wanted also to check with @pnkfelix if we want this nomination up or not given that we hadn't assigned the issue yet. |
@rustbot ping llvm |
Hey LLVM ICE-breakers! This bug has been identified as a good cc @camelid @comex @cuviper @DutchGhost @hanna-kruppe @hdhoang @heyrutvik @JOE1994 @jryans @mmilenko @nagisa @nikic @Noah-Kennedy @SiavoshZarrasvand @spastorino @vertexclique @vgxbj |
self-assigning to 1. verify this is an LLVM bug and if so, 2. isolate .bc file that we can use to file bug against LLVM itself. |
This seems to work fine in rustc 1.54.0 (a178d03 2021-07-26) |
I can still reproduce the bug with rustc 1.54.0 (a178d03 2021-07-26). |
Compiling with
|
When filing a bug to upstream llvm,
@pnkfelix Would you mind if I go ahead and file a bug to upstream llvm? |
I did more investigation to better understand where the compiler is taking so much time.
I kept running & pausing rustc on gdb for >30 minutes (compiler didn't terminate in the meantime).
|
This is definitely not an infinite loop. Replacing the
From what I can tell LLVM ends up unconditionally unrolling all 3 loops here, producing n³ instruction sets of %n = getelementptr inbounds [5 x [5 x [5 x { i8, i8 }]]], [5 x [5 x [5 x { i8, i8 }]]]* %0, i64 0, i64 4, i64 4, i64 3, i32 1
store i8 ..., i8* %n, align 1 At N=50, there will be 250k instructions in a single function, which will naturally take quite a long time to process. |
I filed https://bugs.llvm.org/show_bug.cgi?id=52123 but not holding my breath about this being resolved quickly – there are a couple similar issues on the tracker: https://bugs.llvm.org/show_bug.cgi?id=51922 |
I tried this code:
I expected to see this happen:
(Above command eventually should terminate)
Instead, this happened: Compiler doesn't terminate.
Meta
rustc --version --verbose
:A crate with the repro can be found here: https://github.com/io12/llvm-rustc-bug-repro.
It seems like this is an LLVM bug.
The text was updated successfully, but these errors were encountered: