Closed
Description
In the following example, there's an unnecessary drop flag (and an associated cleanup path) for the result of the S.id()
call. This is only present in beta and nightly, stable does not have this drop flag.
#![crate_type="rlib"]
struct S;
impl Drop for S {
fn drop(&mut self) {
}
}
impl S {
fn id(self) -> Self { self }
fn other(self, s: Self) {}
}
pub fn test() {
let x = S.other(S.id());
}
IR in stable:
bb2: ; preds = %start
store i8 0, i8* %_5, !dbg !47
invoke void @_ZN8rust_out1S5other17he982095737f244abE()
to label %bb3 unwind label %cleanup, !dbg !47
IR in beta/nightly
bb2: ; preds = %start
store i8 1, i8* %_6, !dbg !47
store i8 0, i8* %_5, !dbg !47
store i8 0, i8* %_6, !dbg !47
invoke void @_ZN8rust_out1S5other17hbd876dece79ff804E()
to label %bb4 unwind label %cleanup1, !dbg !47
LLVM is able to remove the unnecessary flag and the drop call, but cannot remove the extraneous landing pads.