-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.Category: This is a bug.F-explicit_tail_calls`#![feature(explicit_tail_calls)]``#![feature(explicit_tail_calls)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-incomplete-featuresThis issue requires the use of incomplete features.This issue requires the use of incomplete features.
Description
Essentially the meat of #144293 (comment) and #144232 (comment)
We want to resolve the span_bug
in
rust/compiler/rustc_codegen_ssa/src/mir/block.rs
Line 1059 in 7cd9505
span_bug!( |
LLVM is currently emitted wrongly for instances with indirect operands, mostly due to cleanup after the fact. Can see this by the MIR of tests/ui/explicit-tail-call/recursion-etc-u64wrapper.rs
:
fn count(_1: U64Wrapper, _2: U64Wrapper) -> U64Wrapper {
debug curr => _1;
debug top => _2;
let mut _0: U64Wrapper;
let mut _3: bool;
let mut _4: u64;
let mut _5: u64;
let mut _6: u64;
let mut _7: U64Wrapper;
let mut _8: u64;
let mut _9: u64;
let mut _10: (u64, bool);
let mut _11: std::string::String;
let mut _12: U64Wrapper;
let mut _13: bool;
bb0: {
_13 = const false;
_13 = const true;
_5 = copy (_1.0: u64);
_4 = std::hint::black_box::<u64>(move _5) -> [return: bb1, unwind: bb6];
}
bb1: {
_6 = copy (_2.0: u64);
_3 = Ge(move _4, move _6);
switchInt(move _3) -> [0: bb3, otherwise: bb2];
}
bb2: {
_13 = const false;
_0 = move _1;
drop(_2) -> [return: bb5, unwind: bb9];
}
bb3: {
_9 = copy (_1.0: u64);
_10 = AddWithOverflow(copy _9, const 1_u64);
assert(!move (_10.1: bool), "attempt to compute `{} + {}`, which would overflow", move _9, const 1_u64) -> [success: bb4, unwind: bb6];
}
bb4: {
_8 = move (_10.0: u64);
_13 = const false;
_11 = move (_1.1: std::string::String);
_7 = U64Wrapper { x: move _8, arbitrary: move _11 };
_12 = move _2;
tailcall count(Spanned { node: move _7, span: r.rs:24:13: 27:14 (#0) }, Spanned { node: move _12, span: r.rs:28:13: 28:16 (#0) });
}
bb5: {
return;
}
bb6 (cleanup): {
drop(_2) -> [return: bb9, unwind terminate(cleanup)];
}
bb7 (cleanup): {
resume;
}
bb8 (cleanup): {
drop((_1.1: std::string::String)) -> [return: bb7, unwind terminate(cleanup)];
}
bb9 (cleanup): {
switchInt(copy _13) -> [0: bb7, otherwise: bb8];
}
}
I believe the only real work involved would be migrating the bbs related to cleanup before the tailcall, or placing the object explicitly on the stack for LLVM's byval
to clean it up for us.
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.Category: This is a bug.F-explicit_tail_calls`#![feature(explicit_tail_calls)]``#![feature(explicit_tail_calls)]`I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.requires-incomplete-featuresThis issue requires the use of incomplete features.This issue requires the use of incomplete features.