[clang] Basic, Sema: introduce `__attribute__((__personality__(...)))` (PR #185225)
Saleem Abdulrasool via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 9 10:46:35 PDT 2026
================
@@ -1655,6 +1655,15 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
PGO->verifyCounterMap();
+ if (CurCodeDecl->hasAttr<PersonalityAttr>()) {
+ StringRef Identifier =
+ CurCodeDecl->getAttr<PersonalityAttr>()->getRoutine()->getName();
+ llvm::FunctionCallee PersonalityRoutine =
+ CGM.CreateRuntimeFunction(llvm::FunctionType::get(CGM.Int32Ty, true),
----------------
compnerd wrote:
I think that the current type is correct for a couple of reasons: it is generally the default C signature and it matches what we actually use for the personality routines elsewhere.
Ultimately, we _cannot_ know the personality signature without doubt. Off the top of my head, there are at least three possible signatures:
MSVC:
```c
EXCEPTION_DISPOSITION (*)(EHExceptionRecord *, EHRegistrationNode *, void *, DispatcherContext *);
```
Itanium:
```
_Unwind_Reason_Code (*)(int, _Unwind_Action, uint64_t, struct _Unwind_Exception *, struct _Unwind_Context *);
```
EHABI:
```
_Unwind_Reason_Code (*)(_Unwind_State state, _Unwind_Control_Block *, _Unwind_Context *);
```
The reason that we need the personality routine specification is because you are interacting with the host environment's model, and we cannot fully ascertain that. We could be building for an environment where we want to interact with both the Itanium model and the SEH models, in which case you want two different signatures.
The common way to represent this in C is really `int (*)(...);`.
I don't think that we want to document what to expect from the personality routine, that would require documenting the various exception models and their unwinding.
https://github.com/llvm/llvm-project/pull/185225
More information about the cfe-commits
mailing list