1 ; RUN: llc %s -o - | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
6 $__clang_call_terminate = comdat any
8 @_ZL11ShouldThrow = internal unnamed_addr global i1 false, align 1
9 @_ZTIi = external constant ptr
10 @str = private unnamed_addr constant [20 x i8] c"Threw an exception!\00"
12 ; Function Attrs: uwtable
13 define void @_Z6throwsv() personality ptr @__gxx_personality_v0 {
15 ; CHECK-LABEL: _Z6throwsv:
17 ; CHECK-NEXT: .cfi_def_cfa_offset 8
19 ; CHECK-NEXT: .LBB0_1:
20 ; CHECK-NEXT: .cfi_def_cfa_offset 16
23 %.b5 = load i1, ptr @_ZL11ShouldThrow, align 1
24 br i1 %.b5, label %if.then, label %try.cont
26 if.then: ; preds = %entry
27 %exception = tail call ptr @__cxa_allocate_exception(i64 4)
28 store i32 1, ptr %exception, align 16
29 invoke void @__cxa_throw(ptr %exception, ptr @_ZTIi, ptr null)
30 to label %unreachable unwind label %lpad
32 lpad: ; preds = %if.then
33 %0 = landingpad { ptr, i32 }
35 %1 = extractvalue { ptr, i32 } %0, 0
36 %2 = tail call ptr @__cxa_begin_catch(ptr %1)
37 %puts = tail call i32 @puts(ptr @str)
38 invoke void @__cxa_rethrow() #4
39 to label %unreachable unwind label %lpad1
41 lpad1: ; preds = %lpad
42 %3 = landingpad { ptr, i32 }
44 invoke void @__cxa_end_catch()
45 to label %eh.resume unwind label %terminate.lpad
47 try.cont: ; preds = %entry
50 eh.resume: ; preds = %lpad1
51 resume { ptr, i32 } %3
53 terminate.lpad: ; preds = %lpad1
54 %4 = landingpad { ptr, i32 }
56 %5 = extractvalue { ptr, i32 } %4, 0
57 tail call void @__clang_call_terminate(ptr %5)
60 unreachable: ; preds = %lpad, %if.then
64 declare ptr @__cxa_allocate_exception(i64)
66 declare void @__cxa_throw(ptr, ptr, ptr)
68 declare i32 @__gxx_personality_v0(...)
70 declare ptr @__cxa_begin_catch(ptr)
72 declare void @__cxa_rethrow()
74 declare void @__cxa_end_catch()
76 ; Function Attrs: noinline noreturn nounwind
77 declare void @__clang_call_terminate(ptr)
79 declare void @_ZSt9terminatev()
82 ; Function Attrs: nounwind
83 declare i32 @puts(ptr nocapture readonly)