This should have no real effect in most cases, as e.g. `hidden`
visibility already implies `dso_local` (or at least LLVM IR does not
preserve the `dso_local` setting if the item is already `hidden`), but
it should fix `-Crelocation-model=static` and improve codegen in
executables.
Note that this PR does not exhaustively port the logic in [clang]. Only
the obviously correct portion and what is necessary to fix a regression
from LLVM 12 that relates to `-Crelocation_model=static`.
Fixes #83335
[clang]: 3001d080c8/clang/lib/CodeGen/CodeGenModule.cpp (L945-L1039)
23 lines
470 B
Rust
23 lines
470 B
Rust
// compile-flags: -C no-prepopulate-passes
|
|
|
|
#![crate_type = "lib"]
|
|
|
|
#[no_mangle]
|
|
pub struct F32(f32);
|
|
|
|
// CHECK: define{{.*}}float @add_newtype_f32(float %a, float %b)
|
|
#[inline(never)]
|
|
#[no_mangle]
|
|
pub fn add_newtype_f32(a: F32, b: F32) -> F32 {
|
|
F32(a.0 + b.0)
|
|
}
|
|
|
|
#[no_mangle]
|
|
pub struct F64(f64);
|
|
|
|
// CHECK: define{{.*}}double @add_newtype_f64(double %a, double %b)
|
|
#[inline(never)]
|
|
#[no_mangle]
|
|
pub fn add_newtype_f64(a: F64, b: F64) -> F64 {
|
|
F64(a.0 + b.0)
|
|
}
|