[llvm] 15e3b49 - [llvm] Allow Rust personality name to contain arbitrary prefix (#166095)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 8 13:22:32 PST 2025
Author: nora
Date: 2025-11-08T13:22:27-08:00
New Revision: 15e3b49cb8222b62c281373a75990b5004753cad
URL: https://github.com/llvm/llvm-project/commit/15e3b49cb8222b62c281373a75990b5004753cad
DIFF: https://github.com/llvm/llvm-project/commit/15e3b49cb8222b62c281373a75990b5004753cad.diff
LOG: [llvm] Allow Rust personality name to contain arbitrary prefix (#166095)
LLVM needs to figure out the type of EH personality for various reasons.
To do this, it currently matches against a hardcoded list of names. In
Rust, we would like to mangle our personality function to better support
linking multiple Rust standard libraries via staticlib. We have
currently mangled all symbols except the personality, which remains
unmangled because of this LLVM hardcoding.
Instead, this now does a suffix match of the personality name, which
will work with the mangling scheme used for these internal symbols (e.g.
`_RNvCseCSg29WUqSe_7___rustc12___rust_alloc`).
Companion Rust PR: https://github.com/rust-lang/rust/pull/148413
Added:
Modified:
llvm/lib/IR/EHPersonalities.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/EHPersonalities.cpp b/llvm/lib/IR/EHPersonalities.cpp
index 9297a82e7d2b0..12ae4748e1f4a 100644
--- a/llvm/lib/IR/EHPersonalities.cpp
+++ b/llvm/lib/IR/EHPersonalities.cpp
@@ -47,7 +47,8 @@ EHPersonality llvm::classifyEHPersonality(const Value *Pers) {
.Case("__C_specific_handler", EHPersonality::MSVC_TableSEH)
.Case("__CxxFrameHandler3", EHPersonality::MSVC_CXX)
.Case("ProcessCLRException", EHPersonality::CoreCLR)
- .Case("rust_eh_personality", EHPersonality::Rust)
+ // Rust mangles its personality function, so we can't test exact equality.
+ .EndsWith("rust_eh_personality", EHPersonality::Rust)
.Case("__gxx_wasm_personality_v0", EHPersonality::Wasm_CXX)
.Case("__xlcxx_personality_v1", EHPersonality::XL_CXX)
.Case("__zos_cxx_personality_v2", EHPersonality::ZOS_CXX)
@@ -77,7 +78,8 @@ StringRef llvm::getEHPersonalityName(EHPersonality Pers) {
case EHPersonality::CoreCLR:
return "ProcessCLRException";
case EHPersonality::Rust:
- return "rust_eh_personality";
+ llvm_unreachable(
+ "Cannot get personality name of Rust personality, since it is mangled");
case EHPersonality::Wasm_CXX:
return "__gxx_wasm_personality_v0";
case EHPersonality::XL_CXX:
More information about the llvm-commits
mailing list