-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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 crash: Basic Block does not have terminator! #88043
Comments
Relevant commit range is 5a19ffe...8007b50. Of the 9 landed PRs, the ones that look potentially relevant to codegen are #85020 and #83417. @lrh2000 @tmandry @erikdesjardins @oli-obk |
This passes under Miri, so I suspect that we've exposed an LLVM bug. |
Not sure it's an LLVM bug because it seems the IR is broken even before any LLVM passes. I tried: $ rustc +nightly-2021-08-14 -Cno-prepopulate-passes --emit=llvm-ir src/main.rs -o before.ll
$ opt before.ll # ok
$ rustc +nightly-2021-08-15 -Cno-prepopulate-passes --emit=llvm-ir src/main.rs -o after.ll
$ opt after.ll
opt: after.ll:287:1: error: expected instruction opcode
bb1: ; preds = %bb0
^ Before: https://paste.rs/o7U The What in LLVM is actually running during a -Cno-prepopulate-passes build? |
I think we should do a quick revert and then figure this out without any pressure |
the mir changes are bb2: {
- _0 = const (); // scope 0 at src/main.rs:8:13: 8:19
- drop(_1) -> bb5; // scope 0 at src/main.rs:13:1: 13:2
+ drop(_1) -> bb4; // scope 0 at src/main.rs:13:1: 13:2
}
bb3: {
- _5 = bump() -> [return: bb4, unwind: bb6]; // scope 0 at src/main.rs:10:13: 10:19
+ _5 = bump() -> [return: bb0, unwind: bb5]; // scope 0 at src/main.rs:10:13: 10:19
// mir::Constant
// + span: src/main.rs:10:13: 10:17
// + literal: Const { ty: fn() -> std::option::Option<usize> {bump}, val: Value(Scalar(<ZST>)) }
- }
-
- bb4: {
- goto -> bb0; // scope 0 at src/main.rs:6:5: 12:6
} that seems totally reasonable, so we need to check what codegen_llvm makes of it |
I wonder why the goto collapse only happens if the zst assignment is eliminated. it seems like we need to preserve bb4 in mir or inject it in codegen_llvm, but first we should find out why the goto collapse is happening at all |
There are no control-flow simplification passes after removal of dead local variables, which is why it didn't happen so far. Still, it seems a bit surprising it wasn't reported earlier: pub fn f(_a: Option<String>) -> Option<u32> {
loop {
f(None);
()
}
}
fn main() {
f(None);
} $ rustc +stable a.rs
Basic Block in function '_ZN1a1f17h9901a33e93da62b7E' does not have terminator!
label %4
in function _ZN1a1f17h9901a33e93da62b7E
LLVM ERROR: Broken function found, compilation aborted! Adding a new cleanup pass before codegen would be one way to address this. |
I swear half of my PRs break the compiler 😅 I'm excited for what bugs arise when we start using undef for uninitialized consts... Revert PR: #88056 |
Assigning priority as discussed in the Zulip thread of the Prioritization Working Group. @rustbot label -I-prioritize +P-critical |
The issue was not fixed, it is an LLVM crash on stable as #88043 (comment) shows |
Relabeling regression because #88043 (comment) worked in 1.51.0. It bisects to nightly-2021-03-02 (e37a13c...4f20caa). |
#78360 is the only codegen change in that nightly. @tmiasko @wesleywiser |
Reopening to track the stable-to-stable regression. |
Backport was merged. |
…r=davidtwco Start block is not allowed to have basic block predecessors * The MIR validator is extended to detect potential violations. * The start block has no predecessors after building MIR, so no changes are required there. * The SimplifyCfg could previously violate this requirement when collapsing goto chains, so transformation is disabled for the start block, which also substantially simplifies the implementation. * The LLVM function entry block also must not have basic block predecessors. Previously, to ensure that code generation had to perform necessary adjustments. This now became unnecessary. The motivation behind the change is to align with analogous requirement in LLVM, and to avoid potential latent bugs like the one reported in rust-lang#88043.
The following is minimized from https://crates.io/crates/lalrpop, which is regressed as of nightly-2021-08-15.
The text was updated successfully, but these errors were encountered: