r309226 - Headers: improve ARM EHABI coverage of unwind.h

Evgenii Stepanov via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 22 10:46:57 PDT 2017


As I understand, using compiler-rt as libgcc replacement on ARM is
currently broken because of this change, but I have not looked since
my last message.

On Mon, Aug 21, 2017 at 4:56 PM, Hans Wennborg <hans at chromium.org> wrote:
> Is there something we need for 5.0.0 here?
>
> On Sat, Aug 12, 2017 at 9:58 PM, Saleem Abdulrasool
> <compnerd at compnerd.org> wrote:
>> Yeah, we should adjust that.  Technically, it is `_Unwind_Control_Block on
>> ARM EHABI.  However, _Unwind_Exception is aliased to that, which is why we
>> can use that in the personality routine.  We should adjust the sources for
>> the personality routine.
>>
>> On Fri, Aug 11, 2017 at 1:12 PM, Evgenii Stepanov
>> <eugeni.stepanov at gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> I've noticed that the code in
>>> compiler-rt/lib/builtins/gcc_personality_v0.c refers to
>>> _Unwind_Exception as "struct _Unwind_Exception". With this change, it
>>> is not a struct anymore on ARM. Should that code be fixed, or is it a
>>> problem in this change?
>>>
>>> compiler-rt/lib/builtins/gcc_personality_v0.c:153:23: error:
>>> declaration of 'struct _Unwind_Exception' will not be visible outside
>>> of this function [-Werror,-Wvisibility]
>>> continueUnwind(struct _Unwind_Exception *exceptionObject,
>>>
>>> On Thu, Jul 27, 2017 at 9:46 AM, Hans Wennborg via cfe-commits
>>> <cfe-commits at lists.llvm.org> wrote:
>>> > Merged to 5.0 in r309290.
>>> >
>>> > On Wed, Jul 26, 2017 at 3:55 PM, Saleem Abdulrasool via cfe-commits
>>> > <cfe-commits at lists.llvm.org> wrote:
>>> >> Author: compnerd
>>> >> Date: Wed Jul 26 15:55:23 2017
>>> >> New Revision: 309226
>>> >>
>>> >> URL: http://llvm.org/viewvc/llvm-project?rev=309226&view=rev
>>> >> Log:
>>> >> Headers: improve ARM EHABI coverage of unwind.h
>>> >>
>>> >> Ensure that we define the `_Unwind_Control_Block` structure used on ARM
>>> >> EHABI targets.  This is needed for building libc++abi with the unwind.h
>>> >> from the resource dir.  A minor fallout of this is that we needed to
>>> >> create a typedef for _Unwind_Exception to work across ARM EHABI and
>>> >> non-EHABI targets.  The structure definitions here are based originally
>>> >> on the documentation from ARM under the "Exception Handling ABI for the
>>> >> ARMĀ® Architecture" Section 7.2.  They are then adjusted to more closely
>>> >> reflect the definition in libunwind from LLVM.  Those changes are
>>> >> compatible in layout but permit easier use in libc++abi and help
>>> >> maintain compatibility between libunwind and the compiler provided
>>> >> definition.
>>> >>
>>> >> Modified:
>>> >>     cfe/trunk/lib/Headers/unwind.h
>>> >>
>>> >> Modified: cfe/trunk/lib/Headers/unwind.h
>>> >> URL:
>>> >> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/unwind.h?rev=309226&r1=309225&r2=309226&view=diff
>>> >>
>>> >> ==============================================================================
>>> >> --- cfe/trunk/lib/Headers/unwind.h (original)
>>> >> +++ cfe/trunk/lib/Headers/unwind.h Wed Jul 26 15:55:23 2017
>>> >> @@ -76,7 +76,13 @@ typedef intptr_t _sleb128_t;
>>> >>  typedef uintptr_t _uleb128_t;
>>> >>
>>> >>  struct _Unwind_Context;
>>> >> +#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) ||
>>> >> defined(__ARM_DWARF_EH___))
>>> >> +struct _Unwind_Control_Block;
>>> >> +typedef struct _Unwind_Control_Block _Unwind_Exception; /* Alias */
>>> >> +#else
>>> >>  struct _Unwind_Exception;
>>> >> +typedef struct _Unwind_Exception _Unwind_Exception;
>>> >> +#endif
>>> >>  typedef enum {
>>> >>    _URC_NO_REASON = 0,
>>> >>  #if defined(__arm__) && !defined(__USING_SJLJ_EXCEPTIONS__) && \
>>> >> @@ -109,8 +115,42 @@ typedef enum {
>>> >>  } _Unwind_Action;
>>> >>
>>> >>  typedef void (*_Unwind_Exception_Cleanup_Fn)(_Unwind_Reason_Code,
>>> >> -                                             struct _Unwind_Exception
>>> >> *);
>>> >> +                                             _Unwind_Exception *);
>>> >>
>>> >> +#if defined(__arm__) && !(defined(__USING_SJLJ_EXCEPTIONS__) ||
>>> >> defined(__ARM_DWARF_EH___))
>>> >> +typedef struct _Unwind_Control_Block _Unwind_Control_Block;
>>> >> +typedef uint32_t _Unwind_EHT_Header;
>>> >> +
>>> >> +struct _Unwind_Control_Block {
>>> >> +  uint64_t exception_class;
>>> >> +  void (*exception_cleanup)(_Unwind_Reason_Code, _Unwind_Control_Block
>>> >> *);
>>> >> +  /* unwinder cache (private fields for the unwinder's use) */
>>> >> +  struct {
>>> >> +    uint32_t reserved1; /* forced unwind stop function, 0 if not
>>> >> forced */
>>> >> +    uint32_t reserved2; /* personality routine */
>>> >> +    uint32_t reserved3; /* callsite */
>>> >> +    uint32_t reserved4; /* forced unwind stop argument */
>>> >> +    uint32_t reserved5;
>>> >> +  } unwinder_cache;
>>> >> +  /* propagation barrier cache (valid after phase 1) */
>>> >> +  struct {
>>> >> +    uint32_t sp;
>>> >> +    uint32_t bitpattern[5];
>>> >> +  } barrier_cache;
>>> >> +  /* cleanup cache (preserved over cleanup) */
>>> >> +  struct {
>>> >> +    uint32_t bitpattern[4];
>>> >> +  } cleanup_cache;
>>> >> +  /* personality cache (for personality's benefit) */
>>> >> +  struct {
>>> >> +    uint32_t fnstart;         /* function start address */
>>> >> +    _Unwind_EHT_Header *ehtp; /* pointer to EHT entry header word */
>>> >> +    uint32_t additional;      /* additional data */
>>> >> +    uint32_t reserved1;
>>> >> +  } pr_cache;
>>> >> +  long long int : 0; /* force alignment of next item to 8-byte
>>> >> boundary */
>>> >> +};
>>> >> +#else
>>> >>  struct _Unwind_Exception {
>>> >>    _Unwind_Exception_Class exception_class;
>>> >>    _Unwind_Exception_Cleanup_Fn exception_cleanup;
>>> >> @@ -120,16 +160,18 @@ struct _Unwind_Exception {
>>> >>     * aligned".  GCC has interpreted this to mean "use the maximum
>>> >> useful
>>> >>     * alignment for the target"; so do we. */
>>> >>  } __attribute__((__aligned__));
>>> >> +#endif
>>> >>
>>> >>  typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)(int, _Unwind_Action,
>>> >>
>>> >> _Unwind_Exception_Class,
>>> >> -                                               struct
>>> >> _Unwind_Exception *,
>>> >> +                                               _Unwind_Exception *,
>>> >>                                                 struct _Unwind_Context
>>> >> *,
>>> >>                                                 void *);
>>> >>
>>> >> -typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(
>>> >> -    int, _Unwind_Action, _Unwind_Exception_Class, struct
>>> >> _Unwind_Exception *,
>>> >> -    struct _Unwind_Context *);
>>> >> +typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(int,
>>> >> _Unwind_Action,
>>> >> +
>>> >> _Unwind_Exception_Class,
>>> >> +
>>> >> _Unwind_Exception *,
>>> >> +                                                      struct
>>> >> _Unwind_Context *);
>>> >>  typedef _Unwind_Personality_Fn __personality_routine;
>>> >>
>>> >>  typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context
>>> >> *,
>>> >> @@ -224,13 +266,12 @@ _Unwind_Ptr _Unwind_GetRegionStart(struc
>>> >>
>>> >>  /* DWARF EH functions; currently not available on Darwin/ARM */
>>> >>  #if !defined(__APPLE__) || !defined(__arm__)
>>> >> -
>>> >> -_Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception
>>> >> *);
>>> >> -_Unwind_Reason_Code _Unwind_ForcedUnwind(struct _Unwind_Exception *,
>>> >> -                                         _Unwind_Stop_Fn, void *);
>>> >> -void _Unwind_DeleteException(struct _Unwind_Exception *);
>>> >> -void _Unwind_Resume(struct _Unwind_Exception *);
>>> >> -_Unwind_Reason_Code _Unwind_Resume_or_Rethrow(struct _Unwind_Exception
>>> >> *);
>>> >> +_Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Exception *);
>>> >> +_Unwind_Reason_Code _Unwind_ForcedUnwind(_Unwind_Exception *,
>>> >> _Unwind_Stop_Fn,
>>> >> +                                         void *);
>>> >> +void _Unwind_DeleteException(_Unwind_Exception *);
>>> >> +void _Unwind_Resume(_Unwind_Exception *);
>>> >> +_Unwind_Reason_Code _Unwind_Resume_or_Rethrow(_Unwind_Exception *);
>>> >>
>>> >>  #endif
>>> >>
>>> >> @@ -241,11 +282,11 @@ typedef struct SjLj_Function_Context *_U
>>> >>
>>> >>  void _Unwind_SjLj_Register(_Unwind_FunctionContext_t);
>>> >>  void _Unwind_SjLj_Unregister(_Unwind_FunctionContext_t);
>>> >> -_Unwind_Reason_Code _Unwind_SjLj_RaiseException(struct
>>> >> _Unwind_Exception *);
>>> >> -_Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind(struct _Unwind_Exception
>>> >> *,
>>> >> +_Unwind_Reason_Code _Unwind_SjLj_RaiseException(_Unwind_Exception *);
>>> >> +_Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind(_Unwind_Exception *,
>>> >>                                                _Unwind_Stop_Fn, void
>>> >> *);
>>> >> -void _Unwind_SjLj_Resume(struct _Unwind_Exception *);
>>> >> -_Unwind_Reason_Code _Unwind_SjLj_Resume_or_Rethrow(struct
>>> >> _Unwind_Exception *);
>>> >> +void _Unwind_SjLj_Resume(_Unwind_Exception *);
>>> >> +_Unwind_Reason_Code _Unwind_SjLj_Resume_or_Rethrow(_Unwind_Exception
>>> >> *);
>>> >>
>>> >>  void *_Unwind_FindEnclosingFunction(void *);
>>> >>
>>> >>
>>> >>
>>> >> _______________________________________________
>>> >> cfe-commits mailing list
>>> >> cfe-commits at lists.llvm.org
>>> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>> > _______________________________________________
>>> > cfe-commits mailing list
>>> > cfe-commits at lists.llvm.org
>>> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>>
>>
>> --
>> Saleem Abdulrasool
>> compnerd (at) compnerd (dot) org


More information about the cfe-commits mailing list