[PATCH] D33878: Handle NetBSD specific _Unwind_Ptr

Kamil Rytarowski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 4 07:54:12 PST 2018


krytarowski added inline comments.


================
Comment at: lib/builtins/gcc_personality_v0.c:248
             _Unwind_SetGR(context, __builtin_eh_return_data_regno(0),
-                          (uintptr_t)exceptionObject);
+                          (TYPE_UNWIND_PTR)exceptionObject);
             _Unwind_SetGR(context, __builtin_eh_return_data_regno(1), 0);
----------------
krytarowski wrote:
> compnerd wrote:
> > `_Unwind_SetGR` is declared as: `void _Unwind_SetGR(struct _Unwind_Context *, int, _Unwind_Word);`
> > 
> > So this cast should not be needed.
> Pity on NetBSD this is:
> 
> `void _Unwind_SetGR(struct _Unwind_Context *, int, _Unwind_Ptr);`
> 
> So the 3rd argument differs.
Maybe NetBSD should change the type to `_Unwind_Word` here? @joerg ?


================
Comment at: lib/builtins/gcc_personality_v0.c:250
             _Unwind_SetGR(context, __builtin_eh_return_data_regno(1), 0);
-            _Unwind_SetIP(context, (funcStart + landingPad));
+            _Unwind_SetIP(context, (TYPE_UNWIND_PTR)(funcStart + landingPad));
             return _URC_INSTALL_CONTEXT;
----------------
compnerd wrote:
> Yes, `_Unwind_SetIP` is declared as `void _Unwind_SetIP(struct _Unwind_Context *, _Unwind_Ptr);`, and if NetBSD declares it as `void *`, then the explicit cast is reasonable.
> 
> Didn't NetBSD use GCC at one point?  It seems that GCC too defines `_Unwind_Ptr` as `unsigned int __attribute__((__mode__(__pointer__)))`, making it effectively the same as `uintptr_t`.
> 
> I'm tempted to say that this is a bug in the unwinder in NetBSD.  However, adding a condition here for NetBSD and a cast is not too terrible.
How about `_Unwind_SetIP(context, (_Unwind_Ptr)(funcStart + landingPad));`?


Repository:
  rL LLVM

https://reviews.llvm.org/D33878





More information about the llvm-commits mailing list