1## Verify that the compact unwind entries for two functions with identical 2## unwind information and LSDA aren't folded together; see the comment in 3## UnwindInfoSectionImpl::finalize for why. 4 5# REQUIRES: x86 6# RUN: rm -rf %t; mkdir %t 7# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos11.0 -emit-compact-unwind-non-canonical=true -o %t/lsda.o %s 8# RUN: %lld -dylib --icf=all -lSystem -lc++ -o %t/liblsda.dylib %t/lsda.o 9# RUN: llvm-objdump --macho --syms --unwind-info %t/liblsda.dylib | FileCheck %s 10 11## Check that f and g have the same unwind encoding and LSDA offset (we need to 12## link with ICF above in order to get the LSDA deduplicated), and that their 13## compact unwind entries aren't folded. 14 15# CHECK-LABEL: SYMBOL TABLE: 16# CHECK: [[#%x,G_ADDR:]] {{.*}} __Z1gv 17# CHECK: [[#%x,H_ADDR:]] {{.*}} __Z1hv 18 19# CHECK-LABEL: Contents of __unwind_info section: 20# CHECK: LSDA descriptors 21# CHECK-NEXT: [0]: function offset=[[#%#.8x,G_ADDR]], LSDA offset=[[#%#x,LSDA:]] 22# CHECK-NEXT: [1]: function offset=[[#%#.8x,H_ADDR]], LSDA offset=[[#%#.8x,LSDA]] 23# CHECK-NEXT: Second level indices: 24# CHECK: [1]: function offset=[[#%#.8x,G_ADDR]], encoding[0]=[[#%#x,ENCODING:]] 25# CHECK: [2]: function offset=[[#%#.8x,H_ADDR]], encoding[0]=[[#%#.8x,ENCODING]] 26 27## Generated from the following C++ code built with: 28## clang -target x86_64-apple-macosx11.0 -S -Os -fno-inline -fomit-frame-pointer 29## void f(int i) { throw i; } 30## void g() { try { f(1); } catch (int) {} } 31## void h() { try { f(2); } catch (int) {} } 32 33 .section __TEXT,__text,regular,pure_instructions 34 .globl __Z1fi ## -- Begin function _Z1fi 35__Z1fi: ## @_Z1fi 36 .cfi_startproc 37 pushq %rbx 38 .cfi_def_cfa_offset 16 39 .cfi_offset %rbx, -16 40 movl %edi, %ebx 41 movl $4, %edi 42 callq ___cxa_allocate_exception 43 movl %ebx, (%rax) 44 movq __ZTIi@GOTPCREL(%rip), %rsi 45 movq %rax, %rdi 46 xorl %edx, %edx 47 callq ___cxa_throw 48 .cfi_endproc 49 ## -- End function 50 .globl __Z1gv ## -- Begin function _Z1gv 51__Z1gv: ## @_Z1gv 52Lfunc_begin0: 53 .cfi_startproc 54 .cfi_personality 155, ___gxx_personality_v0 55 .cfi_lsda 16, Lexception0 56 pushq %rax 57 .cfi_def_cfa_offset 16 58Ltmp0: 59 movl $1, %edi 60 callq __Z1fi 61Ltmp1: 62 ud2 63LBB1_2: ## %lpad 64Ltmp2: 65 movq %rax, %rdi 66 callq ___cxa_begin_catch 67 popq %rax 68 jmp ___cxa_end_catch ## TAILCALL 69Lfunc_end0: 70 .cfi_endproc 71 .section __TEXT,__gcc_except_tab 72 .p2align 2, 0x0 73GCC_except_table1: 74Lexception0: 75 .byte 255 ## @LPStart Encoding = omit 76 .byte 155 ## @TType Encoding = indirect pcrel sdata4 77 .uleb128 Lttbase0-Lttbaseref0 78Lttbaseref0: 79 .byte 1 ## Call site Encoding = uleb128 80 .uleb128 Lcst_end0-Lcst_begin0 81Lcst_begin0: 82 .uleb128 Ltmp0-Lfunc_begin0 ## >> Call Site 1 << 83 .uleb128 Ltmp1-Ltmp0 ## Call between Ltmp0 and Ltmp1 84 .uleb128 Ltmp2-Lfunc_begin0 ## jumps to Ltmp2 85 .byte 1 ## On action: 1 86 .uleb128 Ltmp1-Lfunc_begin0 ## >> Call Site 2 << 87 .uleb128 Lfunc_end0-Ltmp1 ## Call between Ltmp1 and Lfunc_end0 88 .byte 0 ## has no landing pad 89 .byte 0 ## On action: cleanup 90Lcst_end0: 91 .byte 1 ## >> Action Record 1 << 92 ## Catch TypeInfo 1 93 .byte 0 ## No further actions 94 .p2align 2, 0x0 95 ## >> Catch TypeInfos << 96 .long __ZTIi@GOTPCREL+4 ## TypeInfo 1 97Lttbase0: 98 .p2align 2, 0x0 99 ## -- End function 100 .section __TEXT,__text,regular,pure_instructions 101 .globl __Z1hv ## -- Begin function _Z1hv 102__Z1hv: ## @_Z1hv 103Lfunc_begin1: 104 .cfi_startproc 105 .cfi_personality 155, ___gxx_personality_v0 106 .cfi_lsda 16, Lexception1 107 pushq %rax 108 .cfi_def_cfa_offset 16 109Ltmp3: 110 movl $2, %edi 111 callq __Z1fi 112Ltmp4: 113 ud2 114LBB2_2: ## %lpad 115Ltmp5: 116 movq %rax, %rdi 117 callq ___cxa_begin_catch 118 popq %rax 119 jmp ___cxa_end_catch ## TAILCALL 120Lfunc_end1: 121 .cfi_endproc 122 .section __TEXT,__gcc_except_tab 123 .p2align 2, 0x0 124GCC_except_table2: 125Lexception1: 126 .byte 255 ## @LPStart Encoding = omit 127 .byte 155 ## @TType Encoding = indirect pcrel sdata4 128 .uleb128 Lttbase1-Lttbaseref1 129Lttbaseref1: 130 .byte 1 ## Call site Encoding = uleb128 131 .uleb128 Lcst_end1-Lcst_begin1 132Lcst_begin1: 133 .uleb128 Ltmp3-Lfunc_begin1 ## >> Call Site 1 << 134 .uleb128 Ltmp4-Ltmp3 ## Call between Ltmp3 and Ltmp4 135 .uleb128 Ltmp5-Lfunc_begin1 ## jumps to Ltmp5 136 .byte 1 ## On action: 1 137 .uleb128 Ltmp4-Lfunc_begin1 ## >> Call Site 2 << 138 .uleb128 Lfunc_end1-Ltmp4 ## Call between Ltmp4 and Lfunc_end1 139 .byte 0 ## has no landing pad 140 .byte 0 ## On action: cleanup 141Lcst_end1: 142 .byte 1 ## >> Action Record 1 << 143 ## Catch TypeInfo 1 144 .byte 0 ## No further actions 145 .p2align 2, 0x0 146 ## >> Catch TypeInfos << 147 .long __ZTIi@GOTPCREL+4 ## TypeInfo 1 148Lttbase1: 149 .p2align 2, 0x0 150 ## -- End function 151.subsections_via_symbols 152