Skip to content

Commit 15e3b49

Browse files
authored
[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: rust-lang/rust#148413
1 parent 02976f5 commit 15e3b49

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/IR/EHPersonalities.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ EHPersonality llvm::classifyEHPersonality(const Value *Pers) {
4747
.Case("__C_specific_handler", EHPersonality::MSVC_TableSEH)
4848
.Case("__CxxFrameHandler3", EHPersonality::MSVC_CXX)
4949
.Case("ProcessCLRException", EHPersonality::CoreCLR)
50-
.Case("rust_eh_personality", EHPersonality::Rust)
50+
// Rust mangles its personality function, so we can't test exact equality.
51+
.EndsWith("rust_eh_personality", EHPersonality::Rust)
5152
.Case("__gxx_wasm_personality_v0", EHPersonality::Wasm_CXX)
5253
.Case("__xlcxx_personality_v1", EHPersonality::XL_CXX)
5354
.Case("__zos_cxx_personality_v2", EHPersonality::ZOS_CXX)
@@ -77,7 +78,8 @@ StringRef llvm::getEHPersonalityName(EHPersonality Pers) {
7778
case EHPersonality::CoreCLR:
7879
return "ProcessCLRException";
7980
case EHPersonality::Rust:
80-
return "rust_eh_personality";
81+
llvm_unreachable(
82+
"Cannot get personality name of Rust personality, since it is mangled");
8183
case EHPersonality::Wasm_CXX:
8284
return "__gxx_wasm_personality_v0";
8385
case EHPersonality::XL_CXX:

0 commit comments

Comments
 (0)