xref: /llvm-project/llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-multi-return.ll (revision c921ac724ff06997bab25715786c98d4926b0c0e)
1; RUN: not --crash llc < %s -enable-emscripten-cxx-exceptions -mattr=+multivalue -target-abi=experimental-mv 2>&1 | FileCheck %s --check-prefix=EH
2; RUN: not --crash llc < %s -enable-emscripten-sjlj -mattr=+multivalue -target-abi=experimental-mv 2>&1 | FileCheck %s --check-prefix=SJLJ
3
4; Currently multivalue returning functions are not supported in Emscripten EH /
5; SjLj. Make sure they error out.
6
7target triple = "wasm32-unknown-unknown"
8
9%struct.__jmp_buf_tag = type { [6 x i32], i32, [32 x i32] }
10
11define void @exception() personality ptr @__gxx_personality_v0 {
12entry:
13  invoke {i32, i32} @foo(i32 3)
14          to label %try.cont unwind label %lpad
15
16lpad:                                             ; preds = %entry
17  %1 = landingpad { ptr, i32 }
18          catch ptr null
19  %2 = extractvalue { ptr, i32 } %1, 0
20  %3 = extractvalue { ptr, i32 } %1, 1
21  %4 = call ptr @__cxa_begin_catch(ptr %2) #2
22  call void @__cxa_end_catch()
23  br label %try.cont
24
25try.cont:                                         ; preds = %entry, %lpad
26  ret void
27}
28
29define void @setjmp_longjmp() {
30entry:
31  %buf = alloca [1 x %struct.__jmp_buf_tag], align 16
32  %call = call i32 @setjmp(ptr %buf) #0
33  call {i32, i32} @foo(i32 3)
34  call void @longjmp(ptr %buf, i32 1) #1
35  unreachable
36}
37
38declare {i32, i32} @foo(i32)
39declare i32 @__gxx_personality_v0(...)
40declare ptr @__cxa_begin_catch(ptr)
41declare void @__cxa_end_catch()
42; Function Attrs: returns_twice
43declare i32 @setjmp(ptr) #0
44; Function Attrs: noreturn
45declare void @longjmp(ptr, i32) #1
46declare ptr @malloc(i32)
47declare void @free(ptr)
48
49attributes #0 = { returns_twice }
50attributes #1 = { noreturn }
51attributes #2 = { nounwind }
52
53; EH: LLVM ERROR: Emscripten EH/SjLj does not support multivalue returns
54; SJLJ: LLVM ERROR: Emscripten EH/SjLj does not support multivalue returns
55