1 ; RUN: llc %s -o - | FileCheck %s
2 ; RUN: llc < %s -stop-after=prologepilog | FileCheck %s --check-prefix=PEI
4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 $__clang_call_terminate = comdat any
9 @_ZL11ShouldThrow = internal unnamed_addr global i1 false, align 1
10 @_ZTIi = external constant ptr
11 @str = private unnamed_addr constant [20 x i8] c"Threw an exception!\00"
13 ; Function Attrs: uwtable
14 define void @_Z6throwsv() #0 personality ptr @__gxx_personality_v0 {
16 ; CHECK-LABEL: _Z6throwsv:
18 ; CHECK-NEXT: .cfi_def_cfa %rsp, 8
20 ; CHECK-NEXT: .LBB0_1:
21 ; CHECK-NEXT: .cfi_def_cfa %rbp, 16
23 ; PEI-LABEL: name: _Z6throwsv
24 ; PEI: frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp
25 ; PEI-NEXT: frame-setup CFI_INSTRUCTION def_cfa_offset 16
26 ; PEI-NEXT: frame-setup CFI_INSTRUCTION offset $rbp, -16
27 ; PEI-NEXT: $rbp = frame-setup MOV64rr $rsp
28 ; PEI-NEXT: frame-setup CFI_INSTRUCTION def_cfa_register $rbp
29 ; PEI-NEXT: frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
30 ; PEI-NEXT: frame-setup PUSH64r undef $rax, implicit-def $rsp, implicit $rsp
31 ; PEI-NEXT: {{^ +}}CFI_INSTRUCTION offset $rbx, -24
33 ; PEI-NEXT: $rsp = frame-destroy ADD64ri32 $rsp, 8, implicit-def dead $eflags
34 ; PEI-NEXT: $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp
35 ; PEI-NEXT: $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp
36 ; PEI-NEXT: frame-destroy CFI_INSTRUCTION def_cfa $rsp, 8
40 %.b5 = load i1, ptr @_ZL11ShouldThrow, align 1
41 br i1 %.b5, label %if.then, label %try.cont
43 if.then: ; preds = %entry
44 %exception = tail call ptr @__cxa_allocate_exception(i64 4)
45 store i32 1, ptr %exception, align 16
46 invoke void @__cxa_throw(ptr %exception, ptr @_ZTIi, ptr null)
47 to label %unreachable unwind label %lpad
49 lpad: ; preds = %if.then
50 %0 = landingpad { ptr, i32 }
52 %1 = extractvalue { ptr, i32 } %0, 0
53 %2 = tail call ptr @__cxa_begin_catch(ptr %1)
54 %puts = tail call i32 @puts(ptr @str)
55 invoke void @__cxa_rethrow()
56 to label %unreachable unwind label %lpad1
58 lpad1: ; preds = %lpad
59 %3 = landingpad { ptr, i32 }
61 invoke void @__cxa_end_catch()
62 to label %eh.resume unwind label %terminate.lpad
64 try.cont: ; preds = %entry
67 eh.resume: ; preds = %lpad1
68 resume { ptr, i32 } %3
70 terminate.lpad: ; preds = %lpad1
71 %4 = landingpad { ptr, i32 }
73 %5 = extractvalue { ptr, i32 } %4, 0
74 tail call void @__clang_call_terminate(ptr %5)
77 unreachable: ; preds = %lpad, %if.then
81 declare ptr @__cxa_allocate_exception(i64)
83 declare void @__cxa_throw(ptr, ptr, ptr)
85 declare i32 @__gxx_personality_v0(...)
87 declare ptr @__cxa_begin_catch(ptr)
89 declare void @__cxa_rethrow()
91 declare void @__cxa_end_catch()
93 ; Function Attrs: noinline noreturn nounwind
94 declare void @__clang_call_terminate(ptr)
96 declare void @_ZSt9terminatev()
98 ; Function Attrs: nounwind
99 declare i32 @puts(ptr nocapture readonly)
101 attributes #0 = { "frame-pointer"="all" }