-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 and build failure: "piece covers entire variable" #35547
Comments
I've recently encountered this when compiling a program from my OS project (just one out of several userland binaries) (Compiling https://github.com/thepowersgang/rust_os/blob/master/Usermode/fileviewer/src/main.rs using
Notably - The function call mentioned does not appear in the file created by |
Occurs up with optimisation levels 1, 2, and With level 1, only a single call is mentioned, and different optimisation levels change the ! numbers |
@bfops - Your branch has bit-rotted against nightly. |
Thanks, fixed! Error still happens for me on the updated branch. |
I've located the last working nightly - Changes between these two revisions: a005b67...0a3180b |
From some (very slow) commit bisecting - it looks like ee977e7 is at fault - but I do not know how (and I'm not 100% sure it is that commit) |
cc @eddyb - The above commit was by you - can you see a reason for it to cause this error? |
This looks lika a LLVM bug, we don't emit |
https://llvm.org/bugs/show_bug.cgi?id=23712 - A similar issue on LLVM's tracker - Caused by bad debug information (incorrect size information for a variable) |
Thanks to
Aka
Is converted into
I can't see anything directly here that fits the two bugs I mentioned above, but I'm not proficient in LLVM IR. |
Strike that last note:
The alloca is for two pointers (128 bits), but the debug information associated with the variable is 64 bits long (Reduced IR thanks to |
@thepowersgang Nice find! |
So here is a smaller case that produces that "incorrect" IR. I'm putting "incorrect" into quotes because it's not completely wrong. The alloca is of a different type than the what the debuginfo says, but that is because the debuginfo only describes a part of the alloca. #![feature(unboxed_closures)]
#![feature(fn_traits)]
#![crate_type="rlib"]
pub trait Trait {}
pub struct Button;
pub struct Callback;
#[inline(never)]
fn other<'a, 'b>(args: (&'a Button, &'b mut Trait)) {
let _ = args;
}
impl<'a, 'b> ::std::ops::FnOnce<(&'a Button, &'b mut Trait)> for Callback
{
type Output = ();
extern "rust-call" fn call_once(self, args: (&'a Button, &'b mut Trait)) {
// self.0.call(args)
other(args)
}
} This generates the following IR (filtered for interesting parts): ; Function Attrs: uwtable
define void @"_ZN155_$LT$lib..Callback$u20$as$u20$core..ops..FnOnce$LT$$LP$$RF$$u27$a$u20$lib..Button$C$$u20$$RF$$u27$b$u20$mut$u20$lib..Trait$u20$$u2b$$u20$$u27$b$RP$$GT$$GT$9call_once17h8c75272c3c1fa0f7E"(%Button* noalias readonly, i8* nonnull, void (i8*)** nonnull) unnamed_addr #1 !dbg !24 {
entry-block:
%arg1 = alloca { %Button*, { i8*, void (i8*)** } }
%args = alloca { %Button*, { i8*, void (i8*)** } }
call void @llvm.dbg.declare(metadata { %Button*, { i8*, void (i8*)** } }* %arg1, metadata !31, metadata !32), !dbg !30
; ...
call void @llvm.dbg.declare(metadata { %Button*, { i8*, void (i8*)** } }* %arg1, metadata !33, metadata !34), !dbg !30
call void @llvm.dbg.declare(metadata { %Button*, { i8*, void (i8*)** } }* %args, metadata !38, metadata !18), !dbg !37
; ...
}
!10 = !DICompositeType(tag: DW_TAG_structure_type, name: "(&lib::Button, &mut Trait)", file: !7, size: 192, align: 64, elements: !11, identifier: "{tuple {&{struct lib/45447b7afbd5e544f7d0f1df0fccd26014d9850130abd3f020b89ff96b82079f/5}}{&mut{trait lib/45447b7afbd5e544f7d0f1df0fccd26014d9850130abd3f020b89ff96b82079f/4}}}")
!13 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "&lib::Button", baseType: !14, size: 64, align: 64)
!16 = !DICompositeType(tag: DW_TAG_structure_type, name: "&mut Trait", scope: !6, file: !7, size: 128, align: 64, elements: !2, identifier: "{&mut{trait lib/45447b7afbd5e544f7d0f1df0fccd26014d9850130abd3f020b89ff96b82079f/4}}")
!31 = !DILocalVariable(arg: 2, scope: !24, file: !5, line: 1, type: !13)
!32 = !DIExpression(DW_OP_deref, DW_OP_plus, 0)
!33 = !DILocalVariable(arg: 3, scope: !24, file: !5, line: 1, type: !16)
!34 = !DIExpression(DW_OP_deref, DW_OP_plus, 8)
!38 = !DILocalVariable(name: "args", scope: !36, file: !5, line: 19, type: !10) There are a couple of problematic things about this IR:
|
Like #36774, this reduced test also appears to fail in older rustc with MIR enabled. I guess that makes sense, since the error is similar and you bisected the same commit to blame. I'm testing with official rustc builds now, not with distro LLVM that we thought was to blame, and also setting |
debuginfo: Handle spread_arg case in MIR-trans in a more stable way. Use `VariableAccess::DirectVariable` instead of `VariableAccess::IndirectVariable` in order not to make LLVM's SROA angry. This is a step towards fixing #36774 and #35547. At least, I can build Cargo with optimizations + debuginfo again. r? @eddyb
debuginfo: Handle spread_arg case in MIR-trans in a more stable way. Use `VariableAccess::DirectVariable` instead of `VariableAccess::IndirectVariable` in order not to make LLVM's SROA angry. This is a step towards fixing #36774 and #35547. At least, I can build Cargo with optimizations + debuginfo again. r? @eddyb
The above fix has fixed my issue. @bfops Does it fix the issue you were encountering? |
My repro is fixed on the latest nightly! I'm happy to close if nobody else has outstanding concerns. |
This aggressive build failure happens consistently if you try to build rust-clippy with
opt-level=1
set. Here's a fork that does it out of the box:https://github.com/bfops/rust-clippy.git
.The text was updated successfully, but these errors were encountered: