Code bloat caused by lack of nounwind attr on `drop_in_place`
As far as I can tell, rustc doesn't mark functions as NoUnwind/NEVER_UNWIND, apart from a handful of broad generalizations like panic=abort or extern "not *-unwind". I saw some scan of function bodies for coroutines , but not for regular functions.
The problem is that when a Drop::drop can't be inlined, it ends up being a potentially-unwinding call, and because unwinding calls can cause more drops, and panics during unwinding are not allowed, every drop then also generates an unwinding landing pad with and a call to panicking::panic_in_cleanup. This basically doubles the amount of drop-related code, and LLVM won't move nor unify calls to unwinding functions.
This affects Arc. It intentionally has a non-inlined drop_slow, which triggers the unwinding bloat:
rust.godbolt.org
Compiler Explorer - Rust (rustc nightly)
use std::sync::Arc; struct Foo { next: Option>, } #[no_mangle] pub fn maybe_foo(foo: Arc, x: bool) -> Arc { let a = Arc::new(Foo { next: Some(foo.clone()) }); let a = Arc::new(Foo { next: Some(foo.clone()) }); let a = Arc::new(Foo {...
Discussion in the ATmosphere