1 ; RUN: llc < %s -enable-emscripten-cxx-exceptions | FileCheck %s --check-prefix=EH
2 ; RUN: llc < %s -enable-emscripten-sjlj | FileCheck %s --check-prefix=SJLJ
3 ; RUN: llc < %s | FileCheck %s --check-prefix=NONE
5 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6 target triple = "wasm32-unknown-unknown"
8 %struct.__jmp_buf_tag = type { [6 x i32], i32, [32 x i32] }
10 define hidden void @exception() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
11 ; EH-LABEL: type exception,@function
12 ; NONE-LABEL: type exception,@function
15 to label %try.cont unwind label %lpad
16 ; EH: call __invoke_void
19 lpad: ; preds = %entry
20 %0 = landingpad { i8*, i32 }
22 %1 = extractvalue { i8*, i32 } %0, 0
23 %2 = extractvalue { i8*, i32 } %0, 1
24 %3 = call i8* @__cxa_begin_catch(i8* %1) #2
25 call void @__cxa_end_catch()
28 try.cont: ; preds = %entry, %lpad
32 define hidden void @setjmp_longjmp() {
33 ; SJLJ-LABEL: type setjmp_longjmp,@function
34 ; NONE-LABEL: type setjmp_longjmp,@function
36 %buf = alloca [1 x %struct.__jmp_buf_tag], align 16
37 %arraydecay = getelementptr inbounds [1 x %struct.__jmp_buf_tag], [1 x %struct.__jmp_buf_tag]* %buf, i32 0, i32 0
38 %call = call i32 @setjmp(%struct.__jmp_buf_tag* %arraydecay) #0
39 %arraydecay1 = getelementptr inbounds [1 x %struct.__jmp_buf_tag], [1 x %struct.__jmp_buf_tag]* %buf, i32 0, i32 0
40 call void @longjmp(%struct.__jmp_buf_tag* %arraydecay1, i32 1) #1
42 ; SJLJ: i32.call saveSetjmp
43 ; SJLJ: i32.call testSetjmp
44 ; NONE: i32.call setjmp
49 declare i32 @__gxx_personality_v0(...)
50 declare i8* @__cxa_begin_catch(i8*)
51 declare void @__cxa_end_catch()
52 ; Function Attrs: returns_twice
53 declare i32 @setjmp(%struct.__jmp_buf_tag*) #0
54 ; Function Attrs: noreturn
55 declare void @longjmp(%struct.__jmp_buf_tag*, i32) #1
56 declare i8* @malloc(i32)
57 declare void @free(i8*)
59 attributes #0 = { returns_twice }
60 attributes #1 = { noreturn }
61 attributes #2 = { nounwind }