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)
20 lines
508 B
Rust
20 lines
508 B
Rust
// no-system-llvm
|
|
// compile-flags: -Coverflow-checks=no -O
|
|
// revisions: YES NO
|
|
// [YES]compile-flags: -Zfewer-names=yes
|
|
// [NO] compile-flags: -Zfewer-names=no
|
|
#![crate_type = "lib"]
|
|
|
|
#[no_mangle]
|
|
pub fn sum(x: u32, y: u32) -> u32 {
|
|
// YES-LABEL: define{{.*}}i32 @sum(i32 %0, i32 %1)
|
|
// YES-NEXT: %3 = add i32 %1, %0
|
|
// YES-NEXT: ret i32 %3
|
|
|
|
// NO-LABEL: define{{.*}}i32 @sum(i32 %x, i32 %y)
|
|
// NO-NEXT: start:
|
|
// NO-NEXT: %z = add i32 %y, %x
|
|
// NO-NEXT: ret i32 %z
|
|
let z = x + y;
|
|
z
|
|
}
|