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; RUN: not --crash llc < %s -enable-emscripten-cxx-exceptions -mtriple=wasm64-unknown-unknown 2>&1 | FileCheck %s --check-prefix=WASM64-EH 5; RUN: not --crash llc < %s -enable-emscripten-sjlj -mtriple=wasm64-unknown-unknown 2>&1 | FileCheck %s --check-prefix=WASM64-SJLJ 6; RUN: not --crash llc < %s -enable-emscripten-cxx-exceptions -exception-model=wasm 2>&1 | FileCheck %s --check-prefix=WASM-EH-EM-EH 7; RUN: not --crash llc < %s -enable-emscripten-sjlj -exception-model=wasm 2>&1 | FileCheck %s --check-prefix=WASM-EH-EM-SJLJ 8 9target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" 10target triple = "wasm32-unknown-unknown" 11 12%struct.__jmp_buf_tag = type { [6 x i32], i32, [32 x i32] } 13 14define void @exception() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { 15; EH-LABEL: type exception,@function 16; NONE-LABEL: type exception,@function 17entry: 18 invoke void @foo(i32 3) 19 to label %invoke.cont unwind label %lpad 20; EH: call invoke_vi 21; EH-NOT: call __invoke_void_i32 22; NONE: call foo 23 24invoke.cont: 25 invoke void @bar() 26 to label %try.cont unwind label %lpad 27; EH: call invoke_v 28; EH-NOT: call __invoke_void 29; NONE: call bar 30 31lpad: ; preds = %entry 32 %0 = landingpad { i8*, i32 } 33 catch i8* null 34 %1 = extractvalue { i8*, i32 } %0, 0 35 %2 = extractvalue { i8*, i32 } %0, 1 36 %3 = call i8* @__cxa_begin_catch(i8* %1) #2 37 call void @__cxa_end_catch() 38 br label %try.cont 39 40try.cont: ; preds = %entry, %lpad 41 ret void 42} 43 44define void @setjmp_longjmp() { 45; SJLJ-LABEL: type setjmp_longjmp,@function 46; NONE-LABEL: type setjmp_longjmp,@function 47entry: 48 %buf = alloca [1 x %struct.__jmp_buf_tag], align 16 49 %arraydecay = getelementptr inbounds [1 x %struct.__jmp_buf_tag], [1 x %struct.__jmp_buf_tag]* %buf, i32 0, i32 0 50 %call = call i32 @setjmp(%struct.__jmp_buf_tag* %arraydecay) #0 51 %arraydecay1 = getelementptr inbounds [1 x %struct.__jmp_buf_tag], [1 x %struct.__jmp_buf_tag]* %buf, i32 0, i32 0 52 call void @longjmp(%struct.__jmp_buf_tag* %arraydecay1, i32 1) #1 53 unreachable 54; SJLJ: call saveSetjmp 55; SJLJ: i32.const emscripten_longjmp 56; SJLJ-NOT: i32.const emscripten_longjmp_jmpbuf 57; SJLJ: call invoke_vii 58; SJLJ-NOT: call "__invoke_void_%struct.__jmp_buf_tag*_i32" 59; SJLJ: call testSetjmp 60 61; NONE: call setjmp 62; NONE: call longjmp 63} 64 65; Tests whether a user function with 'invoke_' prefix can be used 66declare void @invoke_ignoreme() 67define void @test_invoke_ignoreme() { 68; EH-LABEL: type test_invoke_ignoreme,@function 69; SJLJ-LABEL: type test_invoke_ignoreme,@function 70entry: 71 call void @invoke_ignoreme() 72; EH: call invoke_ignoreme 73; SJLJ: call invoke_ignoreme 74 ret void 75} 76 77declare void @foo(i32) 78declare void @bar() 79declare i32 @__gxx_personality_v0(...) 80declare i8* @__cxa_begin_catch(i8*) 81declare void @__cxa_end_catch() 82; Function Attrs: returns_twice 83declare i32 @setjmp(%struct.__jmp_buf_tag*) #0 84; Function Attrs: noreturn 85declare void @longjmp(%struct.__jmp_buf_tag*, i32) #1 86declare i8* @malloc(i32) 87declare void @free(i8*) 88 89attributes #0 = { returns_twice } 90attributes #1 = { noreturn } 91attributes #2 = { nounwind } 92 93; EH: .functype invoke_vi (i32, i32) -> () 94; EH: .import_module invoke_vi, env 95; EH: .import_name invoke_vi, invoke_vi 96; EH-NOT: .functype __invoke_void_i32 97; EH-NOT: .import_module __invoke_void_i32 98; EH-NOT: .import_name __invoke_void_i32 99 100; SJLJ: .functype emscripten_longjmp (i32, i32) -> () 101; SJLJ: .import_module emscripten_longjmp, env 102; SJLJ: .import_name emscripten_longjmp, emscripten_longjmp 103; SJLJ-NOT: .functype emscripten_longjmp_jmpbuf 104; SJLJ-NOT: .import_module emscripten_longjmp_jmpbuf 105; SJLJ-NOT: .import_name emscripten_longjmp_jmpbuf 106 107; WASM64-EH: LLVM ERROR: Emscripten EH/SjLj is not supported with wasm64 yet 108; WASM64-SJLJ: LLVM ERROR: Emscripten EH/SjLj is not supported with wasm64 yet 109; WASM-EH-EM-EH: LLVM ERROR: -exception-model=wasm not allowed with -enable-emscripten-cxx-exceptions 110; WASM-EH-EM-SJLJ: LLVM ERROR: Emscripten SjLj is not supported with Wasm EH yet 111