diff options
| author | Nikita Popov <npopov@redhat.com> | 2025-08-08 12:39:30 +0200 |
|---|---|---|
| committer | Nikita Popov <npopov@redhat.com> | 2025-08-11 12:39:23 +0200 |
| commit | ebef9d7f6387fb0541a0dab48d1cd1f86556df04 (patch) | |
| tree | 56bbcaea12e6bc5e848ddecdb3bf95fcf7c4b90c /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | |
| parent | 2886b36df4a646dd8d82fb65bf0c9d8d96c1f71a (diff) | |
| download | rust-ebef9d7f6387fb0541a0dab48d1cd1f86556df04.tar.gz rust-ebef9d7f6387fb0541a0dab48d1cd1f86556df04.zip | |
Set dead_on_return attribute for indirect arguments
Set the dead_on_return attribute (added in LLVM 21) for arguments that are passed indirectly, but not byval. This indicates that the value of the argument on return does not matter, enabling additional dead store elimination.
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
| -rw-r--r-- | compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp index 588d867bbbf..cd4f80f808c 100644 --- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp +++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp @@ -277,6 +277,7 @@ enum class LLVMRustAttributeKind { FnRetThunkExtern = 41, Writable = 42, DeadOnUnwind = 43, + DeadOnReturn = 44, }; static Attribute::AttrKind fromRust(LLVMRustAttributeKind Kind) { @@ -369,6 +370,12 @@ static Attribute::AttrKind fromRust(LLVMRustAttributeKind Kind) { return Attribute::Writable; case LLVMRustAttributeKind::DeadOnUnwind: return Attribute::DeadOnUnwind; + case LLVMRustAttributeKind::DeadOnReturn: +#if LLVM_VERSION_GE(21, 0) + return Attribute::DeadOnReturn; +#else + report_fatal_error("DeadOnReturn attribute requires LLVM 21 or later"); +#endif } report_fatal_error("bad LLVMRustAttributeKind"); } |
