[LLVMdev] LLVMdev Digest, Vol 85, Issue 50

John McCall rjmccall at apple.com
Thu Jul 28 14:49:48 PDT 2011


On Jul 28, 2011, at 2:22 PM, Peter Lawrence wrote:
> John,
>           I'm still not sure what you're talking about, I have included the assembly
> output from two compilations, one with a user explicit catch-all, one with only an
> implicit cleanup, the DWARF Action Table and Types Table are absolutely identical,
> as are the indexes used to reference the Action Table from the region maps.

What compiler are you talking about, and on what platform?

The results I'm seeing clearly have both gcc and clang on Darwin generating
different LSDAs for your cleanup examples and your catch-all examples.

Here is the output I see from gcc-4.2 for your cleanup example:

	.text
.globl __Z3barv
__Z3barv:
LFB2:
	pushq	%rbp
LCFI0:
	movq	%rsp, %rbp
LCFI1:
	pushq	%rbx
LCFI2:
	subq	$40, %rsp
LCFI3:
	leaq	-17(%rbp), %rdi
	call	__ZN3BobC1Ev
	leaq	-18(%rbp), %rdi
	call	__ZN3BobC1Ev
	leaq	-19(%rbp), %rdi
	call	__ZN3BobC1Ev
LEHB0:
	call	__Z3foov
LEHE0:

<snip>

	.section __TEXT,__gcc_except_tab
GCC_except_table0:
LLSDA2:
	.byte	0xff
	.byte	0xff
	.byte	0x3
	.byte	0x1a
	.set L$set$0,LEHB0-LFB2   # from 
	.long L$set$0
	.set L$set$1,LEHE0-LEHB0
	.long L$set$1
	.set L$set$2,L6-LFB2
	.long L$set$2
	.byte	0x0

i.e. the range of instructions covering the call to foo() has an action table
index of 0, meaning a cleanup.

Here is the output of ToT clang on this code:

__Z3barv:                               ## @_Z3barv
Ltmp5:
	.cfi_startproc
	.cfi_personality 155, ___gxx_personality_v0
Leh_func_begin0:
	.cfi_lsda 16, Lexception0
## BB#0:                                ## %entry
	pushq	%rbp
Ltmp6:
	.cfi_def_cfa_offset 16
Ltmp7:
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
Ltmp8:
	.cfi_def_cfa_register %rbp
	subq	$80, %rsp
	leaq	-8(%rbp), %rdi
	callq	__ZN3BobC1Ev
	leaq	-16(%rbp), %rdi
	callq	__ZN3BobC1Ev
	leaq	-24(%rbp), %rdi
	callq	__ZN3BobC1Ev
Ltmp0:
	callq	__Z3foov
Ltmp1:

<snip>

	.section	__TEXT,__gcc_except_tab
	.align	2
GCC_except_table0:
Lexception0:
	.byte	255                     ## @LPStart Encoding = omit
	.byte	155                     ## @TType Encoding = indirect pcrel sdata4
	.byte	156                     ## @TType base offset
	.space	1
	.byte	3                       ## Call site Encoding = udata4
	.byte	26                      ## Call site table length
                                        ## >> Call Site 1 <<
                                        ##   Call between Ltmp0 and Ltmp1
                                        ##     jumps to Ltmp2
                                        ##   On action: cleanup
Lset0 = Ltmp0-Leh_func_begin0
	.long	Lset0
Lset1 = Ltmp1-Ltmp0
	.long	Lset1
Lset2 = Ltmp2-Leh_func_begin0
	.long	Lset2
	.byte	0

Same thing.

For contrast, here is the result from gcc-4.2 on your catch-all code:

.globl __Z3barv
__Z3barv:
LFB2:
	pushq	%rbp
LCFI0:
	movq	%rsp, %rbp
LCFI1:
LEHB0:
	call	__Z3foov
LEHE0:

<snip>

 .section __TEXT,__gcc_except_tab
	.align 2
GCC_except_table0:
LLSDA2:
	.byte	0xff
	.byte	0x9b
	.byte	0x25
	.byte	0x3
	.byte	0x1a
	.set L$set$0,LEHB0-LFB2
	.long L$set$0
	.set L$set$1,LEHE0-LEHB0
	.long L$set$1
	.set L$set$2,L6-LFB2
	.long L$set$2
	.byte	0x1   # <-- a non-zero index into the action table
	.set L$set$3,LEHB1-LFB2
	.long L$set$3
	.set L$set$4,LEHE1-LEHB1
	.long L$set$4
	.long	0x0
	.byte	0x0
	.byte	0x1  # <-- first entry (index=1) in the action table
	.byte	0x0
	.align 2
	.long	0  # <-- the first entry (index=1) in the types table, a catch-all

And from ToT Clang:

__Z3barv:                               ## @_Z3barv
Ltmp5:
	.cfi_startproc
	.cfi_personality 155, ___gxx_personality_v0
Leh_func_begin0:
	.cfi_lsda 16, Lexception0
## BB#0:                                ## %entry
	pushq	%rbp
Ltmp6:
	.cfi_def_cfa_offset 16
Ltmp7:
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
Ltmp8:
	.cfi_def_cfa_register %rbp
	subq	$32, %rsp
Ltmp0:
	callq	__Z3foov
Ltmp1:


	.section	__TEXT,__gcc_except_tab
	.align	2
GCC_except_table0:
Lexception0:
	.byte	255                     ## @LPStart Encoding = omit
	.byte	155                     ## @TType Encoding = indirect pcrel sdata4
	.byte	162                     ## @TType base offset
	.space	2,128
	.space	1
	.byte	3                       ## Call site Encoding = udata4
	.byte	26                      ## Call site table length
                                        ## >> Call Site 1 <<
                                        ##   Call between Ltmp0 and Ltmp1
                                        ##     jumps to Ltmp2
                                        ##   On action: 1
Lset0 = Ltmp0-Leh_func_begin0
	.long	Lset0
Lset1 = Ltmp1-Ltmp0
	.long	Lset1
Lset2 = Ltmp2-Leh_func_begin0
	.long	Lset2
	.byte	1
                                        ## >> Call Site 2 <<
                                        ##   Call between Ltmp1 and Leh_func_end0
                                        ##     has no landing pad
Lset3 = Ltmp1-Leh_func_begin0
	.long	Lset3
Lset4 = Leh_func_end0-Ltmp1
	.long	Lset4
	.long	0
	.byte	0
                                        ## >> Action Record 1 <<
                                        ##   Catch TypeInfo 1
                                        ##   No further actions
	.byte	1
	.byte	0
                                        ## >> Catch TypeInfos <<
	.long	0                       ## TypeInfo 1

John.



More information about the llvm-dev mailing list