<br><br><div class="gmail_quote">2010/1/22 Duncan Sands <span dir="ltr"><<a href="mailto:baldrick@free.fr">baldrick@free.fr</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi James,<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I've been trying to get a minimal test function to work, which simply invokes _Unwind_RaiseException with a single clean-up landing pad. However. when I run it my personality function is not getting called - _Unwind_RaiseException simply returns apparently doing nothing. Looking at the x86-64 assembly output from llc, I can see this is happening because the personality function is not getting into the DWARF eh table (the landing pad is there though).<br>

</blockquote>
<br></div>
do you mean that the personality function doesn't turn up in the assembler<br>
at all?  It should be!  Consider the following simplified example:<br></blockquote><div><br>Yes - no reference to the personality function at all. I tried Bill Wendling's suggestion to add an i8* null to the llvm.eh.selector.i64 parameter list but I still get no reference to the personality function. Compared to your example my eh table seems to be missing a load of stuff. The complete LLVM generated x86-64 assembler for my function including eh table is:<br>
<br>    .text<br>    .align    16<br>    .globl    _ZN4N0014Main5test5EN2IO6WriterEiA_l<br>    .type    _ZN4N0014Main5test5EN2IO6WriterEiA_l,@function<br>_ZN4N0014Main5test5EN2IO6WriterEiA_l:                       # @_ZN4N0014Main5test5EN2IO6WriterEiA_l<br>
.Leh_func_begin153:<br>.Lfunc_begin153:<br>.LBB153_0:                                                  # %entry<br>    subq    $56, %rsp<br>.Llabel294:<br>.LBB153_1:<br>    movq    %rdi, 24(%rsp)<br>    movq    %rsi, 48(%rsp)<br>
    movl    %edx, 44(%rsp)<br>    movq    %rcx, 32(%rsp)<br>.LBB153_2:                                                  # %.try_body<br>    movq    32(%rsp), %rdi<br>.Llabel291:<br>    addq    $16, %rdi<br>    xorb    %al, %al<br>
    call    _Unwind_RaiseException<br>.Llabel292:<br>    jmp    .LBB153_4<br>.LBB153_3:                                                  # %.finally_pad<br>.Llabel293:<br>    movq    %rax, 16(%rsp)<br>    testq    %rdx, %rdx<br>
    setne    %al<br>    movzbl    %al, %eax<br>    movq    %rax, (%rsp)<br>.LBB153_4:                                                  # %.finally_handler<br>    movl    $.L__string_27, %edi<br>    xorb    %al, %al<br>    call    printf<br>
    xorl    %eax, %eax<br>    addq    $56, %rsp<br>    ret<br>    .size    _ZN4N0014Main5test5EN2IO6WriterEiA_l, .-_ZN4N0014Main5test5EN2IO6WriterEiA_l<br>.Lfunc_end153:<br>.Leh_func_end153:<br>    .section    .gcc_except_table,"a",@progbits<br>
    .align    4<br>GCC_except_table153:<br>    .byte    0x0                                         # Padding<br>.Lexception153:<br>    .byte    0xFF                                        # @LPStart format (DW_EH_PE_omit)<br>
    .byte    0x0                                         # @TType format (DW_EH_PE_absptr)<br>    .uleb128    28                                  # @TType base offset<br>    .byte    0x3                                         # Call site format (DW_EH_PE_udata4)<br>
    .uleb128    26                                  # Call site table size<br>    .long    .Llabel291-.Leh_func_begin153               # Region start<br>    .long    .Llabel292-.Llabel291                       # Region length<br>
    .long    .Llabel293-.Leh_func_begin153               # Landing pad<br>    .uleb128    0                                   # Action<br>    .long    .Llabel292-.Leh_func_begin153               # Region start<br>    .long    .Leh_func_end153-.Llabel292                 # Region length<br>
    .long    0x0                                         # Landing pad<br>    .uleb128    0                                   # Action<br>    .align    4<br><br><br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>
declare void @g()<br>
<br>
define void @f() {<br>
e:<br>
  invoke void @g()<br>
          to label %c unwind label %u<br>
<br>
c:                                                ; preds = %e<br>
  ret void<br>
<br>
u:                                                ; preds = %e<br>
  %ptr = tail call i8* @llvm.eh.exception() nounwind ; <i8*> [#uses=1]<br>
  %select = tail call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %ptr, i8* bitcast (i32 (...)* @personality to i8*)) nounwind ; <i32> [#uses=0]<br>
  ret void<br>
}<br>
<br>
declare i8* @llvm.eh.exception() nounwind readonly<br>
<br>
declare i32 @llvm.eh.selector(i8*, i8*, ...) nounwind<br>
<br>
declare i32 @personality(...)<br>
<br>
<br>
<br>
This compiles down to the following, which has a "cleanup" noted in the<br>
dwarf eh table, and has the personality function recorded in the CIE.<br>
This is with llc from top-of-tree.  Do you see something different?<br>
<br>
Ciao,<br>
<br>
Duncan.<br>
<br>
<br>
<br>
        .file   "selector.ll"<br>
<br>
<br>
        .text<br>
        .align  16<br>
.globl f<br>
        .type   f,@function<br>
f:                                                          # @f<br>
.Leh_func_begin1:<br>
# BB#0:                                                     # %e<br>
        subq    $8, %rsp<br>
.Llabel4:<br>
.Llabel1:<br>
        callq   g<br>
.Llabel2:<br>
# BB#1:                                                     # %c<br>
        addq    $8, %rsp<br>
        ret<br>
.LBB1_2:<br>
                                                            # %u<br>
.Llabel3:<br>
        addq    $8, %rsp<br>
        ret<br>
        .size   f, .-f<br>
.Leh_func_end1:<div class="im"><br>
        .section        .gcc_except_table,"a",@progbits<br>
        .align  4<br></div>
GCC_except_table1:<br>
        .byte   0<br>
                                                            # Padding<br>
        .byte   0<br>
                                                            # Padding<br>
.Lexception1:<br>
        .byte   255<br>
                                                            # @LPStart format (omit)<br>
        .byte   0<br>
                                                            # @TType format (absptr)<br>
        .uleb128        15                                  # @TType base offset<br>
        .byte   3<br>
                                                            # Call site format (udata4)<br>
        .uleb128        13                                  # Call site table size<br>
        .long   .Llabel1-.Leh_func_begin1                   # Region start<br>
        .long   .Llabel2-.Llabel1                           # Region length<br>
        .long   .Llabel3-.Leh_func_begin1                   # Landing pad<br>
        .uleb128        0                                   # Action<br>
        .align  4<br>
        .section        .eh_frame,"aw",@progbits<br>
.LEH_frame0:<br>
.Lsection_eh_frame:<br>
.Leh_frame_common:<br>
        .long   .Leh_frame_common_end-.Leh_frame_common_begin # Length of Common Information Entry<br>
.Leh_frame_common_begin:<br>
        .long   0<br>
                                                            # CIE Identifier Tag<br>
        .byte   1<br>
                                                            # CIE Version<br>
        .asciz  "zPLR"                                      # CIE Augmentation<br>
        .uleb128        1                                   # CIE Code Alignment Factor<br>
        .sleb128        -8                                  # CIE Data Alignment Factor<br>
        .byte   16<br>
                                                            # CIE Return Address Column<br>
        .uleb128        7                                   # Augmentation Size<br>
        .byte   27<br>
                                                            # Personality (pcrel sdata4)<br>
.Lpersonalityref_addr1_0:<br>
        .long   personality-.Lpersonalityref_addr1_0        # Personality<br>
        .byte   27<br>
                                                            # LSDA Encoding (pcrel sdata4)<br>
        .byte   27<br>
                                                            # FDE Encoding (pcrel sdata4)<br>
        .byte   12<br>
                                                            # DW_CFA_def_cfa<br>
        .uleb128        7                                   # Register<br>
        .uleb128        8                                   # Offset<br>
        .byte   144<br>
                                                            # DW_CFA_offset + Reg (16)<br>
        .uleb128        1                                   # Offset<br>
        .align  8<br>
.Leh_frame_common_end:<br>
<br>
.Lf.eh:<br>
        .long   .Leh_frame_end1-.Leh_frame_begin1           # Length of Frame Information Entry<br>
.Leh_frame_begin1:<br>
        .long   .Leh_frame_begin1-.Leh_frame_common         # FDE CIE offset<br>
        .long   .Leh_func_begin1-.                          # FDE initial location<br>
        .long   .Leh_func_end1-.Leh_func_begin1             # FDE address range<br>
        .uleb128        8                                   # Augmentation size<br>
        .quad   .Lexception1-.                              # Language Specific Data Area<br>
        .byte   4<br>
                                                            # DW_CFA_advance_loc4<br>
        .long   .Llabel4-.Leh_func_begin1<br>
        .byte   14<br>
                                                            # DW_CFA_def_cfa_offset<br>
        .uleb128        16                                  # Offset<br>
        .align  8<br>
.Leh_frame_end1:<br>
<br>
<br>
        .section        .note.GNU-stack,"",@progbits<br>
<br>
</blockquote></div><br>