[clang] [libcxxabi] [libunwind] [llvm] [WebAssembly] Call EH personality function instead of `Unwind_CallPersonality` (PR #209282)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 13 12:47:46 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,c,h -- libunwind/include/unwind_wasm.h clang/lib/CodeGen/CGException.cpp libcxxabi/src/cxa_personality.cpp libunwind/include/unwind.h libunwind/src/Unwind-wasm.c libunwind/src/config.h llvm/lib/CodeGen/WasmEHPrepare.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp
index 25b57a033..4076ab5dc 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -272,8 +272,7 @@ static llvm::FunctionCallee getPersonalityFn(CodeGenModule &CGM,
   } else {
     FTy = llvm::FunctionType::get(CGM.Int32Ty, true);
   }
-  return CGM.CreateRuntimeFunction(FTy,
-                                   Personality.PersonalityFn,
+  return CGM.CreateRuntimeFunction(FTy, Personality.PersonalityFn,
                                    llvm::AttributeList(), /*Local=*/true);
 }
 
diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp
index 9348c7cfe..92767efa5 100644
--- a/libcxxabi/src/cxa_personality.cpp
+++ b/libcxxabi/src/cxa_personality.cpp
@@ -1011,7 +1011,7 @@ static inline void get_landing_pad(__cxa_catch_temp_type &dest,
 #endif
 }
 
-#if (defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)) || defined(__WASM_EXCEPTIONS__)
+#  if (defined(__SEH__) && !defined(__USING_SJLJ_EXCEPTIONS__)) || defined(__WASM_EXCEPTIONS__)
 static _Unwind_Reason_Code __gxx_personality_imp
 #else
 _LIBCXXABI_FUNC_VIS _Unwind_Reason_Code
@@ -1112,23 +1112,19 @@ __gxx_personality_seh0(PEXCEPTION_RECORD ms_exc, void *this_frame,
 }
 #endif
 
-
-#ifdef __WASM_EXCEPTIONS__
-extern "C" _LIBCXXABI_FUNC_VIS
-void __gxx_wasm_personality_v0(void* exception_ptr) {
-  struct _Unwind_Exception *exception_object =
-      (struct _Unwind_Exception *)exception_ptr;
+#  ifdef __WASM_EXCEPTIONS__
+extern "C" _LIBCXXABI_FUNC_VIS void __gxx_wasm_personality_v0(void* exception_ptr) {
+  struct _Unwind_Exception* exception_object = (struct _Unwind_Exception*)exception_ptr;
 
   // Reset the selector.
   __wasm_lpad_context.selector = 0;
 
   // Call personality function. Wasm does not have two-phase unwinding, so we
   // only do the search phase.
-  __gxx_personality_imp(
-      1, _UA_SEARCH_PHASE, exception_object->exception_class, exception_object,
-      (struct _Unwind_Context *)&__wasm_lpad_context);
+  __gxx_personality_imp(1, _UA_SEARCH_PHASE, exception_object->exception_class, exception_object,
+                        (struct _Unwind_Context*)&__wasm_lpad_context);
 }
-#endif
+#  endif
 
 #else
 
diff --git a/libunwind/src/config.h b/libunwind/src/config.h
index fd1aba25e..73162995f 100644
--- a/libunwind/src/config.h
+++ b/libunwind/src/config.h
@@ -75,13 +75,14 @@
   #define _LIBUNWIND_EXPORT
   #define _LIBUNWIND_HIDDEN
 #else
-  #if !defined(__ELF__) && !defined(__MACH__) && !defined(_AIX) && !defined(__wasm__)
-    #define _LIBUNWIND_EXPORT __declspec(dllexport)
-    #define _LIBUNWIND_HIDDEN
-  #else
-    #define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
-    #define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
-  #endif
+#if !defined(__ELF__) && !defined(__MACH__) && !defined(_AIX) &&               \
+    !defined(__wasm__)
+#define _LIBUNWIND_EXPORT __declspec(dllexport)
+#define _LIBUNWIND_HIDDEN
+#else
+#define _LIBUNWIND_EXPORT __attribute__((visibility("default")))
+#define _LIBUNWIND_HIDDEN __attribute__((visibility("hidden")))
+#endif
 #endif
 
 #define STR(a) #a
diff --git a/llvm/lib/CodeGen/WasmEHPrepare.cpp b/llvm/lib/CodeGen/WasmEHPrepare.cpp
index 363e7221f..ab562edff 100644
--- a/llvm/lib/CodeGen/WasmEHPrepare.cpp
+++ b/llvm/lib/CodeGen/WasmEHPrepare.cpp
@@ -259,8 +259,8 @@ bool WasmEHPrepareImpl::prepareEHPads(Function &F) {
   // instruction selection.
   CatchF = Intrinsic::getOrInsertDeclaration(&M, Intrinsic::wasm_catch);
 
-  auto *PersPrototype = FunctionType::get(
-      IRB.getInt32Ty(), {IRB.getPtrTy()}, false);
+  auto *PersPrototype =
+      FunctionType::get(IRB.getInt32Ty(), {IRB.getPtrTy()}, false);
   PersonalityF =
       M.getOrInsertFunction(getEHPersonalityName(Personality), PersPrototype);
 
@@ -354,11 +354,10 @@ void WasmEHPrepareImpl::prepareEHPad(BasicBlock *BB, bool NeedPersonality,
 
   // Grab direct function when possible to use `call` instead of `call_indirect`
   if (Function *F = dyn_cast<Function>(PersonalityF.getCallee()))
-    PersCI = IRB.CreateCall(F, CatchCI,
-                            OperandBundleDef("funclet", CPI));
+    PersCI = IRB.CreateCall(F, CatchCI, OperandBundleDef("funclet", CPI));
   else
-    PersCI = IRB.CreateCall(PersonalityF, CatchCI,
-                            OperandBundleDef("funclet", CPI));
+    PersCI =
+        IRB.CreateCall(PersonalityF, CatchCI, OperandBundleDef("funclet", CPI));
 
   PersCI->setDoesNotThrow();
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/209282


More information about the cfe-commits mailing list