[PATCH] D15781: [compiler-rt] Add support for ARM EHABI to gcc_personality_v0.

Logan Chien via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 28 16:31:42 PST 2015


logan added a comment.

In http://reviews.llvm.org/D15781#317439, @compnerd wrote:

> Also, neighter LLVM nor GCC would produce references to this personality routine, so it seems odd to support this.


No.  Both GCC and LLVM do generate references to `__gcc_personality_v0` with `__attribute__((cleanup(func)))` when the command line option `-fexceptions` is given.  For example,

  #include <stdio.h>
  
  extern void may_throw();
  
  void my_cleanup(int *p) {
    printf("%d\n", *p);
  }
  
  void test() {
    int a __attribute__((cleanup(my_cleanup))) = 10;
    may_throw();
  }



> Why is it unsafe to use the well defined personality routines for ARM and rust?  They are required for unwinding to work on ARM.  The index and unwind tables have to be generated specifically for use with them, so the code generation is already aware of the existence.


Which well-defined personality routines are you referring to?  Are you referring to the C++ one, i.e. `__gxx_personality_v0()`?  I guess that they don't need the complexity of the complete C++ personality.

> Finally, I think that if you generate the personality references correctly on the rust side, you won't need the __gcc_personality_v0 unless there is C code trying to handle exceptions.


I am not familiar with the Rust compiler.  However, I believe they are leveraging LLVM code generators to translate `landingpad` instructions to exception handlers, LSDA, etc.  In the other words, they are not generating LSDA by themselves.  Besides, LLVM will only generate either Dwarf or SJLJ LSDA, so IMO it is OK to reuse `__gcc_personality_v0` if Rust compiler (or ABI) does not have extra requirements on the personality function.

BTW, I don't think there is any problem to fix the personality for C language.


http://reviews.llvm.org/D15781





More information about the llvm-commits mailing list