-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #83592 - nagisa:nagisa/dso_local, r=davidtwco
Set dso_local for hidden, private and local items This should probably 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 portion that is necessary to fix a regression from LLVM 12 that relates to `-Crelocation_model=static`. Fixes #83335 [clang]: https://github.com/llvm/llvm-project/blob/3001d080c813da20b329303bf8f45451480e5905/clang/lib/CodeGen/CodeGenModule.cpp#L945-L1039
- Loading branch information
Showing
30 changed files
with
221 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// min-llvm-version: 12.0.0 | ||
// needs-llvm-components: aarch64 x86 | ||
// revisions:X64 A64 | ||
// assembly-output: emit-asm | ||
// [X64] compile-flags: --target x86_64-unknown-linux-gnu -Crelocation-model=static | ||
// [A64] compile-flags: --target aarch64-unknown-linux-gnu -Crelocation-model=static | ||
|
||
#![feature(no_core, lang_items)] | ||
#![no_core] | ||
#![crate_type="rlib"] | ||
|
||
#[lang="sized"] | ||
trait Sized {} | ||
|
||
#[lang="copy"] | ||
trait Copy {} | ||
|
||
impl Copy for u8 {} | ||
|
||
extern "C" { | ||
fn chaenomeles(); | ||
} | ||
|
||
// CHECK-LABEL: banana: | ||
// x64: movb chaenomeles, %{{[a,z]+}} | ||
// A64: adrp [[REG:[a-z0-9]+]], chaenomeles | ||
// A64-NEXT: ldrb {{[a-z0-9]+}}, {{\[}}[[REG]], :lo12:chaenomeles] | ||
#[no_mangle] | ||
pub fn banana() -> u8 { | ||
unsafe { | ||
*(chaenomeles as *mut u8) | ||
} | ||
} | ||
|
||
// CHECK-LABEL: peach: | ||
// x64: movb banana, %{{[a,z]+}} | ||
// A64: adrp [[REG2:[a-z0-9]+]], banana | ||
// A64-NEXT: ldrb {{[a-z0-9]+}}, {{\[}}[[REG2]], :lo12:banana] | ||
#[no_mangle] | ||
pub fn peach() -> u8 { | ||
unsafe { | ||
*(banana as *mut u8) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
// Checks if the correct annotation for the sysv64 ABI is passed to | ||
// llvm. Also checks that the abi-sysv64 feature gate allows usage | ||
// of the sysv64 abi. | ||
|
||
// ignore-arm | ||
// ignore-aarch64 | ||
// ignore-riscv64 sysv64 not supported | ||
|
||
// compile-flags: -C no-prepopulate-passes | ||
// | ||
// needs-llvm-components: x86 | ||
// compile-flags: -C no-prepopulate-passes --target=x86_64-unknown-linux-gnu | ||
|
||
#![crate_type = "lib"] | ||
#![no_core] | ||
#![feature(abi_x86_interrupt, no_core, lang_items)] | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
#[lang = "copy"] | ||
trait Copy {} | ||
|
||
// CHECK: define x86_64_sysvcc i64 @has_sysv64_abi | ||
#[no_mangle] | ||
pub extern "sysv64" fn has_sysv64_abi(a: i64) -> i64 { | ||
a * 2 | ||
a | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.