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