[LLVMdev] ARM c++ exceptions handling not working with clang/llvm-3.2?

Abdoulaye Walsimou GAYE awg at embtoolkit.org
Mon Feb 4 12:08:16 PST 2013


Hello,
am I wrong or the ARM c++ exceptions handling does not work?
See the difference between assembly generated by clang and gcc
with the following test code:

#include <stdio.h>
#include <exception>

# test.cpp
int main()
{
     try {
         throw 20;
     } catch (int e) {
         printf("Exception Nr %d occurred\n", e);
     }

     return 0;
}

tools-armel-linux-arm920t/bin/armel-unknown-linux-gnueabi-clang++ -v -save-temps -mcpu=arm920t -std=c++11 test.cpp -o test
clang version 3.2 (tags/RELEASE_32/final)
Target: armel-unknown-linux-gnueabi
Thread model: posix
  "/home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/armel-unknown-linux-gnueabi-clang" -cc1 -triple armv4t-unknown-linux-gnueabi -E -disable-free -main-file-name test.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -mconstructor-aliases -fuse-init-array -target-abi aapcs-linux -target-cpu arm920t -msoft-float -mfloat-abi soft -target-feature +soft-float -target-feature +soft-float-abi -target-feature -neon -target-linker-version 2.22 -momit-leaf-frame-pointer -v -resource-dir /home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/../lib/clang/3.2 -isysroot /home/walsimou/embtoolkit.git/sysroot-armel-linux-arm920t -fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/../lib/gcc/armel-unknown-linux-gnueabi/4.7.3/../../../../armel-unknown-linux-gnueabi/include/c++/4.7.3 -internal-isystem 
/home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/../lib/gcc/armel-unknown-linux-gnueabi/4.7.3/../../../../armel-unknown-linux-gnueabi/include/c++/4.7.3/armel-unknown-linux-gnueabi -internal-isystem /home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/../lib/gcc/armel-unknown-linux-gnueabi/4.7.3/../../../../armel-unknown-linux-gnueabi/include/c++/4.7.3/backward -internal-isystem /home/walsimou/embtoolkit.git/sysroot-armel-linux-arm920t/usr/local/include -internal-isystem /home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/../lib/clang/3.2/include -internal-externc-isystem /home/walsimou/embtoolkit.git/sysroot-armel-linux-arm920t/include -internal-externc-isystem /home/walsimou/embtoolkit.git/sysroot-armel-linux-arm920t/usr/include -std=c++11 -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-dir /home/walsimou/embtoolkit.git -ferror-limit 19 -fmessage-length 212 -mstackrealign -fno-signed-char -fobjc-runtime=gcc -fcxx-exceptions 
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o test.ii -x c++ test.cpp
clang -cc1 version 3.2 based upon LLVM 3.2svn default target armel-unknown-linux-gnueabi
ignoring nonexistent directory "/home/walsimou/embtoolkit.git/sysroot-armel-linux-arm920t/usr/local/include"
ignoring nonexistent directory "/home/walsimou/embtoolkit.git/sysroot-armel-linux-arm920t/include"
#include "..." search starts here:
#include <...> search starts here:
  /home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/../lib/gcc/armel-unknown-linux-gnueabi/4.7.3/../../../../armel-unknown-linux-gnueabi/include/c++/4.7.3
  /home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/../lib/gcc/armel-unknown-linux-gnueabi/4.7.3/../../../../armel-unknown-linux-gnueabi/include/c++/4.7.3/armel-unknown-linux-gnueabi
  /home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/../lib/gcc/armel-unknown-linux-gnueabi/4.7.3/../../../../armel-unknown-linux-gnueabi/include/c++/4.7.3/backward
  /home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/../lib/clang/3.2/include
  /home/walsimou/embtoolkit.git/sysroot-armel-linux-arm920t/usr/include
End of search list.
  "/home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/armel-unknown-linux-gnueabi-clang" -cc1 -triple armv4t-unknown-linux-gnueabi -S -disable-free -main-file-name test.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -mconstructor-aliases -fuse-init-array -target-abi aapcs-linux -target-cpu arm920t -msoft-float -mfloat-abi soft -target-feature +soft-float -target-feature +soft-float-abi -target-feature -neon -target-linker-version 2.22 -momit-leaf-frame-pointer -v -resource-dir /home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/../lib/clang/3.2 -std=c++11 -fdeprecated-macro -fno-dwarf-directory-asm -fdebug-compilation-dir /home/walsimou/embtoolkit.git -ferror-limit 19 -fmessage-length 212 -mstackrealign -fno-signed-char -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o test.s -x c++-cpp-output test.ii
clang -cc1 version 3.2 based upon LLVM 3.2svn default target armel-unknown-linux-gnueabi
#include "..." search starts here:
End of search list.
  "/home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/armel-unknown-linux-gnueabi-as" -mfloat-abi=soft -mcpu=arm920t -o test.o test.s
  "/home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/armel-unknown-linux-gnueabi-ld" --sysroot=/home/walsimou/embtoolkit.git/sysroot-armel-linux-arm920t -z relro -X --hash-style=gnu --build-id --eh-frame-hdr -m armelf_linux_eabi -dynamic-linker /lib/ld-linux.so.3 -o test /home/walsimou/embtoolkit.git/sysroot-armel-linux-arm920t/usr/lib/crt1.o /home/walsimou/embtoolkit.git/sysroot-armel-linux-arm920t/usr/lib/crti.o /home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/../lib/gcc/armel-unknown-linux-gnueabi/4.7.3/crtbegin.o -L/home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/../lib/gcc/armel-unknown-linux-gnueabi/4.7.3 -L/home/walsimou/embtoolkit.git/sysroot-armel-linux-arm920t/lib -L/home/walsimou/embtoolkit.git/sysroot-armel-linux-arm920t/usr/lib test.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /home/walsimou/embtoolkit.git/tools-armel-linux-arm920t/bin/../lib/gcc/armel-unknown-linux-gnueabi/4.7.3/crtend.o 
/home/walsimou/embtoolkit.git/sysroot-armel-linux-arm920t/usr/lib/crtn.o

----- CLANG/LLVM-3.2 assembly out--------
     .syntax unified
     .eabi_attribute 6, 2
     .eabi_attribute 20, 1
     .eabi_attribute 21, 1
     .eabi_attribute 23, 3
     .eabi_attribute 24, 1
     .eabi_attribute 25, 1
     .file    "test.ii"
     .text
     .globl    main
     .align    2
     .type    main,%function
main:
     push    {r11, lr}
     mov    r11, sp
     sub    sp, sp, #24
     mov    r0, #0
     str    r0, [r11, #-4]
     mov    r1, #4
     str    r0, [sp, #4]
     mov    r0, r1
     bl    __cxa_allocate_exception
     mov    r1, #20
     str    r1, [r0]
     ldr    r1, .LCPI0_0
     ldr    r2, [sp, #4]
     bl    __cxa_throw
     .align    2
.LCPI0_0:
     .long    _ZTIi
.Ltmp0:
     .size    main, .Ltmp0-main

     .type    .L.str,%object
     .section    .rodata.str1.1,"aMS",%progbits,1
.L.str:
     .asciz     "Exception Nr %d occurred\n"
     .size    .L.str, 26

----- GCC assembly output --------
     .cpu arm920t
     .fpu softvfp
     .eabi_attribute 20, 1
     .eabi_attribute 21, 1
     .eabi_attribute 23, 3
     .eabi_attribute 24, 1
     .eabi_attribute 25, 1
     .eabi_attribute 26, 2
     .eabi_attribute 30, 6
     .eabi_attribute 34, 0
     .eabi_attribute 18, 4
     .file    "test.cpp"
     .section    .rodata
     .align    2
.LC0:
     .ascii    "Exception Nr %d occurred\012\000"
     .text
     .align    2
     .global    main
     .type    main, %function
main:
     .fnstart
.LFB6:
     @ Function supports interworking.
     @ args = 0, pretend = 0, frame = 8
     @ frame_needed = 1, uses_anonymous_args = 0
     stmfd    sp!, {fp, lr}
     .save {fp, lr}
     .setfp fp, sp, #4
     add    fp, sp, #4
     .pad #8
     sub    sp, sp, #8
     mov    r0, #4
     bl    __cxa_allocate_exception
     mov    r3, r0
     mov    r2, #20
     str    r2, [r3, #0]
     mov    r0, r3
     ldr    r1, .L9
     mov    r2, #0
.LEHB0:
     bl    __cxa_throw
.LEHE0:
.L8:
     bl    __cxa_end_catch
.LEHB1:
     bl    __cxa_end_cleanup
.L7:
     mov    r3, r0
     mov    r2, r1
     cmp    r2, #1
     beq    .L6
     bl    __cxa_end_cleanup
.LEHE1:
.L6:
     mov    r0, r3
     bl    __cxa_begin_catch
     mov    r3, r0
     ldr    r3, [r3, #0]
     str    r3, [fp, #-8]
     ldr    r0, .L9+4
     ldr    r1, [fp, #-8]
.LEHB2:
     bl    printf
.LEHE2:
     bl    __cxa_end_catch
     mov    r3, #0
     mov    r0, r3
     sub    sp, fp, #4
     ldmfd    sp!, {fp, lr}
     bx    lr
.L10:
     .align    2
.L9:
     .word    _ZTIi
     .word    .LC0
     .global    __gxx_personality_v0
     .personality    __gxx_personality_v0
     .handlerdata
     .align    2
.LLSDA6:
     .byte    0xff
     .byte    0
     .uleb128 .LLSDATT6-.LLSDATTD6
.LLSDATTD6:
     .byte    0x1
     .uleb128 .LLSDACSE6-.LLSDACSB6
.LLSDACSB6:
     .uleb128 .LEHB0-.LFB6
     .uleb128 .LEHE0-.LEHB0
     .uleb128 .L7-.LFB6
     .uleb128 0x1
     .uleb128 .LEHB1-.LFB6
     .uleb128 .LEHE1-.LEHB1
     .uleb128 0
     .uleb128 0
     .uleb128 .LEHB2-.LFB6
     .uleb128 .LEHE2-.LEHB2
     .uleb128 .L8-.LFB6
     .uleb128 0
.LLSDACSE6:
     .byte    0x1
     .byte    0
     .align    2
     .word    _ZTIi(TARGET2)
.LLSDATT6:
     .text
     .fnend
     .size    main, .-main
     .ident    "GCC: (embtoolkit-00149-g2857df9) 4.7.3 20121216 (prerelease)"
     .section    .note.GNU-stack,"",%progbits





More information about the llvm-dev mailing list