1; RUN: not --crash llc < %s -enable-emscripten-cxx-exceptions -mattr=+multivalue 2>&1 | FileCheck %s --check-prefix=EH
2; RUN: not --crash llc < %s -enable-emscripten-sjlj -mattr=+multivalue 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 i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
12entry:
13  invoke {i32, i32} @foo(i32 3)
14          to label %try.cont unwind label %lpad
15
16lpad:                                             ; preds = %entry
17  %1 = landingpad { i8*, i32 }
18          catch i8* null
19  %2 = extractvalue { i8*, i32 } %1, 0
20  %3 = extractvalue { i8*, i32 } %1, 1
21  %4 = call i8* @__cxa_begin_catch(i8* %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  %arraydecay = getelementptr inbounds [1 x %struct.__jmp_buf_tag], [1 x %struct.__jmp_buf_tag]* %buf, i32 0, i32 0
33  %call = call i32 @setjmp(%struct.__jmp_buf_tag* %arraydecay) #0
34  %arraydecay1 = getelementptr inbounds [1 x %struct.__jmp_buf_tag], [1 x %struct.__jmp_buf_tag]* %buf, i32 0, i32 0
35  call {i32, i32} @foo(i32 3)
36  call void @longjmp(%struct.__jmp_buf_tag* %arraydecay1, i32 1) #1
37  unreachable
38}
39
40declare {i32, i32} @foo(i32)
41declare i32 @__gxx_personality_v0(...)
42declare i8* @__cxa_begin_catch(i8*)
43declare void @__cxa_end_catch()
44; Function Attrs: returns_twice
45declare i32 @setjmp(%struct.__jmp_buf_tag*) #0
46; Function Attrs: noreturn
47declare void @longjmp(%struct.__jmp_buf_tag*, i32) #1
48declare i8* @malloc(i32)
49declare void @free(i8*)
50
51attributes #0 = { returns_twice }
52attributes #1 = { noreturn }
53attributes #2 = { nounwind }
54
55; EH: LLVM ERROR: Emscripten EH/SjLj does not support multivalue returns
56; SJLJ: LLVM ERROR: Emscripten EH/SjLj does not support multivalue returns
57