1# Test that landing pads at fragment entries are not omitted during unwinding. 2# This uses profile2 splitting with a fake fdata, so SplitFunctions splits main 3# right before landing pad. 4 5# RUN: llvm-mc --filetype=obj --triple x86_64-unknown-unknown %s -o %t.o 6# RUN: link_fdata %s %t.o %t.fdata 7# RUN: llvm-strip --strip-unneeded %t.o 8# RUN: %clang++ %cflags %t.o -o %t.exe -Wl,-q 9# RUN: llvm-bolt %t.exe -o %t.bolt --split-functions --data=%t.fdata \ 10# RUN: --print-split --print-only=main --split-eh --split-all-cold \ 11# RUN: 2>&1 | FileCheck --check-prefix=BOLT-CHECK %s 12# RUN: %t.bolt | FileCheck --check-prefix=RUN-CHECK %s 13 14# BOLT-CHECK: ------- HOT-COLD SPLIT POINT ------- 15# BOLT-CHECK-EMPTY: 16# BOLT-CHECK-NEXT: .LLP1 17 18# RUN-CHECK: failed successfully 19 20 21 .text 22 .file "lp-fragment-start.cpp" 23 .globl main # -- Begin function main 24 .p2align 4, 0x90 25 .type main,@function 26main: # @main 27.Lfunc_begin0: 28 .cfi_startproc 29 .cfi_personality 155, DW.ref.__gxx_personality_v0 30 .cfi_lsda 27, .Lexception0 31 pushq %r15 32 .cfi_def_cfa_offset 16 33 pushq %r14 34 .cfi_def_cfa_offset 24 35 pushq %rbx 36 .cfi_def_cfa_offset 32 37 .cfi_offset %rbx, -32 38 .cfi_offset %r14, -24 39 .cfi_offset %r15, -16 40 movl $16, %edi 41LL_fdata0: 42 callq __cxa_allocate_exception@PLT 43# FDATA: 1 main #LL_fdata0# 1 __cxa_allocate_exception@PLT 0 0 1 44 movq %rax, %rbx 45.Ltmp0: 46 leaq .L.str(%rip), %rsi 47 movq %rax, %rdi 48 callq _ZNSt13runtime_errorC1EPKc@PLT 49 jmp .Ltmp3 50.Ltmp1: 51# Cause split here, so .Ltmp5 is the first block of the fragment 52.Ltmp5: # LP for .Ltmp3 to .Ltmp4 53 movq %rdx, %r15 54 movq %rax, %r14 55 jmp .LBB0_4 56.Ltmp3: # throw std::runtime_error 57 movq _ZTISt13runtime_error@GOTPCREL(%rip), %rsi 58 movq _ZNSt13runtime_errorD1Ev@GOTPCREL(%rip), %rdx 59 movq %rbx, %rdi 60 callq __cxa_throw@PLT # LP: .Ltmp5 61.Ltmp4: 62.Ltmp2: 63 movq %rdx, %r15 64 movq %rax, %r14 65 movq %rbx, %rdi 66 callq __cxa_free_exception@PLT 67.LBB0_4: 68 movq %r14, %rdi 69 cmpl $1, %r15d 70 jne .LBB0_5 71 callq __cxa_begin_catch@PLT 72 movq (%rax), %rcx 73 movq %rax, %rdi 74 callq *16(%rcx) 75 movq %rax, %rdi 76 callq puts@PLT 77 callq __cxa_end_catch@PLT 78 xorl %eax, %eax 79 popq %rbx 80 .cfi_def_cfa_offset 24 81 popq %r14 82 .cfi_def_cfa_offset 16 83 popq %r15 84 .cfi_def_cfa_offset 8 85 retq 86.LBB0_5: 87 .cfi_def_cfa_offset 32 88 callq _Unwind_Resume@PLT 89.Lfunc_end0: 90 .size main, .Lfunc_end0-main 91 .cfi_endproc 92 .section .gcc_except_table,"a",@progbits 93 .p2align 2 94GCC_except_table0: 95.Lexception0: 96 .byte 255 # @LPStart Encoding = omit 97 .byte 155 # @TType Encoding = indirect pcrel sdata4 98 .uleb128 .Lttbase0-.Lttbaseref0 99.Lttbaseref0: 100 .byte 1 # Call site Encoding = uleb128 101 .uleb128 .Lcst_end0-.Lcst_begin0 102.Lcst_begin0: 103 .uleb128 .Lfunc_begin0-.Lfunc_begin0 # >> Call Site 1 << 104 .uleb128 .Ltmp0-.Lfunc_begin0 # Call between .Lfunc_begin0 and .Ltmp0 105 .byte 0 # has no landing pad 106 .byte 0 # On action: cleanup 107 .uleb128 .Ltmp0-.Lfunc_begin0 # >> Call Site 2 << 108 .uleb128 .Ltmp1-.Ltmp0 # Call between .Ltmp0 and .Ltmp1 109 .uleb128 .Ltmp2-.Lfunc_begin0 # jumps to .Ltmp2 110 .byte 3 # On action: 2 111 .uleb128 .Ltmp3-.Lfunc_begin0 # >> Call Site 3 << 112 .uleb128 .Ltmp4-.Ltmp3 # Call between .Ltmp3 and .Ltmp4 113 .uleb128 .Ltmp5-.Lfunc_begin0 # jumps to .Ltmp5 114 .byte 5 # On action: 3 115 .uleb128 .Ltmp4-.Lfunc_begin0 # >> Call Site 4 << 116 .uleb128 .Lfunc_end0-.Ltmp4 # Call between .Ltmp4 and .Lfunc_end0 117 .byte 0 # has no landing pad 118 .byte 0 # On action: cleanup 119.Lcst_end0: 120 .byte 0 # >> Action Record 1 << 121 .byte 0 # No further actions 122 .byte 1 # >> Action Record 2 << 123 .byte 125 # Continue to action 1 124 .byte 1 # >> Action Record 3 << 125 .byte 0 # No further actions 126 .p2align 2 127.Ltmp6: # TypeInfo 1 128 .long .L_ZTISt13runtime_error.DW.stub-.Ltmp6 129.Lttbase0: 130 .p2align 2 131 .type .L.str,@object # @.str 132 .section .rodata.str1.1,"aMS",@progbits,1 133.L.str: 134 .asciz "failed successfully" 135 .size .L.str, 20 136 137 .data 138 .p2align 3 139.L_ZTISt13runtime_error.DW.stub: 140 .quad _ZTISt13runtime_error 141 .hidden DW.ref.__gxx_personality_v0 142 .weak DW.ref.__gxx_personality_v0 143 .section .data.DW.ref.__gxx_personality_v0,"aGw",@progbits,DW.ref.__gxx_personality_v0,comdat 144 .p2align 3 145 .type DW.ref.__gxx_personality_v0,@object 146 .size DW.ref.__gxx_personality_v0, 8 147DW.ref.__gxx_personality_v0: 148 .quad __gxx_personality_v0 149 .ident "clang version 14.0.0 (https://github.com/llvm/llvm-project.git 329fda39c507e8740978d10458451dcdb21563be)" 150 .section ".note.GNU-stack","",@progbits 151 .addrsig 152 .addrsig_sym __gxx_personality_v0 153 .addrsig_sym _Unwind_Resume 154 .addrsig_sym _ZTISt13runtime_error 155 156 157# #include <cstdio> 158# #include <stdexcept> 159# 160# int main() { 161# try { 162# throw std::runtime_error("failed successfully"); 163# } catch (const std::runtime_error &e) { 164# puts(e.what()); 165# } 166# return 0; 167# } 168