aheejin wrote:

Sorry for the late reply. My email filter wasn't set up right...

> There is also some work to be done to support other personality functions in 
> WebAssembly. Basic code generation with the wrong personality function works 
> with [this](https://github.com/llvm/llvm-project/pull/171038) patch.
> 
> 1. Clang emits `_Unwind_CallPersonality` (defined in 
> [libunwind/src/Unwind-wasm.c](https://github.com/llvm/llvm-project/blob/80ec43d455a5e47ba005112cd2b2c447bb40c42c/libunwind/src/Unwind-wasm.c#L58))
>  which always calls `__gxx_personality_wasm0`.

Calls to `_Unwind_CallPersonality` are emitted not in Clang but WasmEHPrepare:
https://github.com/llvm/llvm-project/blob/f440b5c12df500f86f9407e625d42f92913e8367/llvm/lib/CodeGen/WasmEHPrepare.cpp#L370-L372

> 2. WebAssembly catchpads are emitted based on the return value of 
> `isWasmPersonality`.
> 3. WasmEHPrepare hard-codes and reports a fatal error if the personality 
> function is not `__gxx_wasm_personality_v0`
>    
> https://github.com/llvm/llvm-project/blob/80ec43d455a5e47ba005112cd2b2c447bb40c42c/llvm/lib/CodeGen/WasmEHPrepare.cpp#L238-L244
> 
> The personality `__gxx_personality_wasm0` is implemented in 
> [libcxxabi/src/cxa_personality.cpp](https://github.com/llvm/llvm-project/blob/80ec43d455a5e47ba005112cd2b2c447bb40c42c/libcxxabi/src/cxa_personality.cpp#L1019).
> 
> I would like to avoid defining two new personality functions for ObjC and 
> ObjCXX on WASM. Can't we just differentiate and emit code based on the target 
> triple?

I think the name of the personality function can be either the same or 
different, depending on your preference. Even if the name is the same, the 
library you link will be different (i.e., it's not going to be libc++), so as 
long as the signature matches the name doesn't matter much. It would be 
slightly simpler if your personality function has the same name because we 
don't need to fix WasmEHPrepare though.

https://github.com/llvm/llvm-project/pull/169043
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to