This is an archive of the discontinued LLVM Phabricator instance.

Implement ARM EHABI exception handling.
ClosedPublic

Authored by logan on May 5 2014, 10:41 AM.

Details

Reviewers
logan
Summary

This commit implements the zero-cost exception handling support
for libc++abi.

Diff Detail

Event Timeline

logan updated this revision to Diff 9082.May 5 2014, 10:41 AM
logan retitled this revision from to Implement ARM EHABI exception handling..
logan updated this object.
logan edited the test plan for this revision. (Show Details)
logan added a subscriber: Unknown Object (MLST).

Thanks for working on this Logan!

include/unwind.h
28

#else
#define LIBCXXABI_ARM_EHABI 0
#endif

70

#7.2 says this should be:
char exception_class[8];

Maybe add a FIXME here for that?

src/cxa_exception.cpp
311

Is this a public interface? or should it be static?

341

Is _Unwind_Resume going to need a manual entry for the .ARM.exidx section for this function so that _Unwind_Resume can find it?

I think it just needs to be a Su16 entry with 3 Finish opcodes.

344

Does this need a
".globl __cxa_end_cleanup\n"
line to make it visible to ld (or does the .type line take care of that)?

345

I'm not sure from reading #8.4.1 and #7.4.6 why this is r1-r4 and not r0-r3... r0 is callee save and likely to get clobbered by the call to isOurExceptionClass in __cxa_end_cleanup_impl, no?

src/cxa_personality.cpp
324

Should we assert that the ttypeEncoding is DW_EH_PE_absptr?

396

Maybe add a comment here to highlight the difference between ARM EHABI and the Itanium ABI, and explain why the implementation needs to be different. On ARM, these are 0-delimited runs of TARGET2 relocation pointers to the typeinfos, whereas in the rest of the Itanium EH ABI, these are 0-delimited runs of uleb128 indexes into the type table.

712

Maybe the part added here should go under #if LIBCXXABI_ARM_EHABI ?

756

Maybe the part added here should go under #if LIBCXXABI_ARM_EHABI ?

logan added a comment.May 6 2014, 9:14 AM

Hi Joerg,

logan added a comment.May 6 2014, 11:42 AM

Thanks for your comments. Will be fixed in next revision.

include/unwind.h
28

Done.

70

I am not sure whether we are going to fix this. There has been several pieces of code using integer arithmetic to determinate whether this is a native exception or foreign exception. I can add the comment if you insist.

src/cxa_exception.cpp
311

No this is not a public interface. When I was writing this code, I have tried to use static. However, this function will be ignored by compiler because there is no function call to this static function.

But now, I have found __attribute__((used)), which can solve the issue. I will change this in the next revision.

341

__cxa_end_cleanup() is a bridge for the cleanup handler to return to unwinder. Thus, we don't have to unwind the stack containing from the cleanup handler. In fact, _Unwind_Resume will load the information from _Unwind_Control_Block, which contains the actual stack to be unwinded.

Thus, it is fine for not having .fnstart and .fnend directives here.

344

I am not sure about this, but this is what clang generates for extern functions. I guess .globl is for the linkage and .type is for the ELF symbol type, thus we need both of them.

345

r0-r3 are caller save registers. However, r0 will (and should) be covered by the return value, thus we don't have to push them to stack. On the other hand, r4 is only pushed for stack alignment.

src/cxa_personality.cpp
324

Done.

396

Done.

712

These won't be needed and will be removed in next revision. (I have fixed the TODO in the phase 2 search. Thus, we don't have to perform the search again.) Thanks.

logan updated this revision to Diff 9118.May 6 2014, 11:50 AM
  • Update the LIBCXXABI_ARM_EHABI condition.
  • Use static to hide __cxa_end_cleanup_impl().
  • Refine the code for exception_spec_can_catch() so that it will look much similar with the Itanium version. Besides, several comments are added to address Jonathan's comment.
  • Load phase 1 result in phase 2 so that we don't have to search for the catch handler again. Besides, we don't have to change scan_eh_tab() any more.

Changes LGTM. Might be a good idea for kledzik or nbjoerg to have a look too, but post-commit review is probably fine for that.

include/unwind.h
70

Ok. It's not super important to me.

src/cxa_exception.cpp
311

Ok. Sounds good.

341

Oh, right.

344

Ok. Doing what clang does for externs sounds good to me.

345

Ohhhhh, I see now.

src/cxa_personality.cpp
712

Ok.

logan updated this revision to Diff 9121.May 6 2014, 12:13 PM

Replace conditional guard with SIZEOF_LONG_DOUBLE * CHAR_BIT.

logan updated this revision to Diff 9227.May 8 2014, 8:38 AM

Use LDBL_MANT_DIGS to distinguish fp80 for demangle test case.

logan accepted this revision.May 9 2014, 5:50 PM
logan added a reviewer: logan.
This revision is now accepted and ready to land.May 9 2014, 5:50 PM
logan closed this revision.May 9 2014, 5:50 PM

Committed as rL208466.