Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions llvm/lib/IR/EHPersonalities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -77,7 +78,8 @@ StringRef llvm::getEHPersonalityName(EHPersonality Pers) {
case EHPersonality::CoreCLR:
return "ProcessCLRException";
case EHPersonality::Rust:
return "rust_eh_personality";
llvm_unreachable(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This worried me enough to audit the callers of this function:

../llvm/include/llvm/IR/EHPersonalities.h:LLVM_ABI StringRef getEHPersonalityName(EHPersonality Pers);
../llvm/lib/IR/EHPersonalities.cpp:StringRef llvm::getEHPersonalityName(EHPersonality Pers) {
../llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp:    StringRef PersName = getEHPersonalityName(EHPersonality::Wasm_CXX);
../llvm/lib/Transforms/Utils/EscapeEnumerator.cpp:  return M->getOrInsertFunction(getEHPersonalityName(Pers),

The most interesting case was the EscapeEnumerator, which needs to compute the name of the default EH personality so it can insert new cleanup landingpads. Presumably the Rust EH personality will never be the platform default EH personality, so there's no correctness issue.

If we wanted to be super-safe we'd make the return value optional or return an empty string, but this seems OK to me as written.

"Cannot get personality name of Rust personality, since it is mangled");
case EHPersonality::Wasm_CXX:
return "__gxx_wasm_personality_v0";
case EHPersonality::XL_CXX:
Expand Down
Loading