[LLVMdev] Exception handling question

Duncan Sands baldrick at free.fr
Fri Jan 22 00:29:59 PST 2010


Hi James,

> 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).

do you mean that the personality function doesn't turn up in the assembler
at all?  It should be!  Consider the following simplified example:

declare void @g()

define void @f() {
e:
   invoke void @g()
           to label %c unwind label %u

c:                                                ; preds = %e
   ret void

u:                                                ; preds = %e
   %ptr = tail call i8* @llvm.eh.exception() nounwind ; <i8*> [#uses=1]
   %select = tail call i32 (i8*, i8*, ...)* @llvm.eh.selector(i8* %ptr, i8* 
bitcast (i32 (...)* @personality to i8*)) nounwind ; <i32> [#uses=0]
   ret void
}

declare i8* @llvm.eh.exception() nounwind readonly

declare i32 @llvm.eh.selector(i8*, i8*, ...) nounwind

declare i32 @personality(...)



This compiles down to the following, which has a "cleanup" noted in the
dwarf eh table, and has the personality function recorded in the CIE.
This is with llc from top-of-tree.  Do you see something different?

Ciao,

Duncan.



	.file	"selector.ll"


	.text
	.align	16
.globl f
	.type	f, at function
f:                                                          # @f
.Leh_func_begin1:
# BB#0:                                                     # %e
	subq	$8, %rsp
.Llabel4:
.Llabel1:
	callq	g
.Llabel2:
# BB#1:                                                     # %c
	addq	$8, %rsp
	ret
.LBB1_2:
                                                             # %u
.Llabel3:
	addq	$8, %rsp
	ret
	.size	f, .-f
.Leh_func_end1:
	.section	.gcc_except_table,"a", at progbits
	.align	4
GCC_except_table1:
	.byte	0
                                                             # Padding
	.byte	0
                                                             # Padding
.Lexception1:
	.byte	255
                                                             # @LPStart format 
(omit)
	.byte	0
                                                             # @TType format 
(absptr)
	.uleb128	15                                  # @TType base offset
	.byte	3
                                                             # Call site format 
(udata4)
	.uleb128	13                                  # Call site table size
	.long	.Llabel1-.Leh_func_begin1                   # Region start
	.long	.Llabel2-.Llabel1                           # Region length
	.long	.Llabel3-.Leh_func_begin1                   # Landing pad
	.uleb128	0                                   # Action
	.align	4
	.section	.eh_frame,"aw", at progbits
.LEH_frame0:
.Lsection_eh_frame:
.Leh_frame_common:
	.long	.Leh_frame_common_end-.Leh_frame_common_begin # Length of Common 
Information Entry
.Leh_frame_common_begin:
	.long	0
                                                             # CIE Identifier Tag
	.byte	1
                                                             # CIE Version
	.asciz	"zPLR"                                      # CIE Augmentation
	.uleb128	1                                   # CIE Code Alignment Factor
	.sleb128	-8                                  # CIE Data Alignment Factor
	.byte	16
                                                             # CIE Return 
Address Column
	.uleb128	7                                   # Augmentation Size
	.byte	27
                                                             # Personality 
(pcrel sdata4)
.Lpersonalityref_addr1_0:
	.long	personality-.Lpersonalityref_addr1_0        # Personality
	.byte	27
                                                             # LSDA Encoding 
(pcrel sdata4)
	.byte	27
                                                             # FDE Encoding 
(pcrel sdata4)
	.byte	12
                                                             # DW_CFA_def_cfa
	.uleb128	7                                   # Register
	.uleb128	8                                   # Offset
	.byte	144
                                                             # DW_CFA_offset + 
Reg (16)
	.uleb128	1                                   # Offset
	.align	8
.Leh_frame_common_end:

.Lf.eh:
	.long	.Leh_frame_end1-.Leh_frame_begin1           # Length of Frame Information 
Entry
.Leh_frame_begin1:
	.long	.Leh_frame_begin1-.Leh_frame_common         # FDE CIE offset
	.long	.Leh_func_begin1-.                          # FDE initial location
	.long	.Leh_func_end1-.Leh_func_begin1             # FDE address range
	.uleb128	8                                   # Augmentation size
	.quad	.Lexception1-.                              # Language Specific Data Area
	.byte	4
                                                             # DW_CFA_advance_loc4
	.long	.Llabel4-.Leh_func_begin1
	.byte	14
                                                             # DW_CFA_def_cfa_offset
	.uleb128	16                                  # Offset
	.align	8
.Leh_frame_end1:


	.section	.note.GNU-stack,"", at progbits



More information about the llvm-dev mailing list