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 4 5target triple = "wasm32-unknown-unknown" 6 7; EH: .functype invoke_vi (i32, i32) -> () 8; EH: .import_module invoke_vi, env 9; EH: .import_name invoke_vi, invoke_vi 10; EH-NOT: .functype __invoke_void_i32 11; EH-NOT: .import_module __invoke_void_i32 12; EH-NOT: .import_name __invoke_void_i32 13 14; SJLJ: .functype emscripten_longjmp (i32, i32) -> () 15; SJLJ: .import_module emscripten_longjmp, env 16; SJLJ: .import_name emscripten_longjmp, emscripten_longjmp 17; SJLJ-NOT: .functype emscripten_longjmp_jmpbuf 18; SJLJ-NOT: .import_module emscripten_longjmp_jmpbuf 19; SJLJ-NOT: .import_name emscripten_longjmp_jmpbuf 20 21%struct.__jmp_buf_tag = type { [6 x i32], i32, [32 x i32] } 22 23define void @exception() personality ptr @__gxx_personality_v0 { 24; EH-LABEL: type exception,@function 25; NONE-LABEL: type exception,@function 26entry: 27 invoke void @foo(i32 3) 28 to label %invoke.cont unwind label %lpad 29; EH: call invoke_vi 30; EH-NOT: call __invoke_void_i32 31; NONE: call foo 32 33invoke.cont: 34 invoke void @bar() 35 to label %try.cont unwind label %lpad 36; EH: call invoke_v 37; EH-NOT: call __invoke_void 38; NONE: call bar 39 40lpad: ; preds = %entry 41 %0 = landingpad { ptr, i32 } 42 catch ptr null 43 %1 = extractvalue { ptr, i32 } %0, 0 44 %2 = extractvalue { ptr, i32 } %0, 1 45 %3 = call ptr @__cxa_begin_catch(ptr %1) #2 46 call void @__cxa_end_catch() 47 br label %try.cont 48 49try.cont: ; preds = %entry, %lpad 50 ret void 51} 52 53define void @setjmp_longjmp() { 54; SJLJ-LABEL: type setjmp_longjmp,@function 55; NONE-LABEL: type setjmp_longjmp,@function 56entry: 57 %buf = alloca [1 x %struct.__jmp_buf_tag], align 16 58 %call = call i32 @setjmp(ptr %buf) #0 59 call void @longjmp(ptr %buf, i32 1) #1 60 unreachable 61; SJLJ: call __wasm_setjmp 62; SJLJ: i32.const emscripten_longjmp 63; SJLJ-NOT: i32.const emscripten_longjmp_jmpbuf 64; SJLJ: call invoke_vii 65; SJLJ-NOT: call "__invoke_void_ptr_i32" 66; SJLJ: call __wasm_setjmp_test 67 68; NONE: call setjmp 69; NONE: call longjmp 70} 71 72; Tests whether a user function with 'invoke_' prefix can be used 73declare void @invoke_ignoreme() 74define void @test_invoke_ignoreme() { 75; EH-LABEL: type test_invoke_ignoreme,@function 76; SJLJ-LABEL: type test_invoke_ignoreme,@function 77entry: 78 call void @invoke_ignoreme() 79; EH: call invoke_ignoreme 80; SJLJ: call invoke_ignoreme 81 ret void 82} 83 84declare void @foo(i32) 85declare void @bar() 86declare i32 @__gxx_personality_v0(...) 87declare ptr @__cxa_begin_catch(ptr) 88declare void @__cxa_end_catch() 89; Function Attrs: returns_twice 90declare i32 @setjmp(ptr) #0 91; Function Attrs: noreturn 92declare void @longjmp(ptr, i32) #1 93declare ptr @malloc(i32) 94declare void @free(ptr) 95 96attributes #0 = { returns_twice } 97attributes #1 = { noreturn } 98attributes #2 = { nounwind } 99