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 datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
8target triple = "wasm32-unknown-unknown"
9
10%struct.__jmp_buf_tag = type { [6 x i32], i32, [32 x i32] }
11
12define void @exception() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
13entry:
14  invoke {i32, i32} @foo(i32 3)
15          to label %try.cont unwind label %lpad
16
17lpad:                                             ; preds = %entry
18  %1 = landingpad { i8*, i32 }
19          catch i8* null
20  %2 = extractvalue { i8*, i32 } %1, 0
21  %3 = extractvalue { i8*, i32 } %1, 1
22  %4 = call i8* @__cxa_begin_catch(i8* %2) #2
23  call void @__cxa_end_catch()
24  br label %try.cont
25
26try.cont:                                         ; preds = %entry, %lpad
27  ret void
28}
29
30define void @setjmp_longjmp() {
31entry:
32  %buf = alloca [1 x %struct.__jmp_buf_tag], align 16
33  %arraydecay = getelementptr inbounds [1 x %struct.__jmp_buf_tag], [1 x %struct.__jmp_buf_tag]* %buf, i32 0, i32 0
34  %call = call i32 @setjmp(%struct.__jmp_buf_tag* %arraydecay) #0
35  %arraydecay1 = getelementptr inbounds [1 x %struct.__jmp_buf_tag], [1 x %struct.__jmp_buf_tag]* %buf, i32 0, i32 0
36  call {i32, i32} @foo(i32 3)
37  call void @longjmp(%struct.__jmp_buf_tag* %arraydecay1, i32 1) #1
38  unreachable
39}
40
41declare {i32, i32} @foo(i32)
42declare i32 @__gxx_personality_v0(...)
43declare i8* @__cxa_begin_catch(i8*)
44declare void @__cxa_end_catch()
45; Function Attrs: returns_twice
46declare i32 @setjmp(%struct.__jmp_buf_tag*) #0
47; Function Attrs: noreturn
48declare void @longjmp(%struct.__jmp_buf_tag*, i32) #1
49declare i8* @malloc(i32)
50declare void @free(i8*)
51
52attributes #0 = { returns_twice }
53attributes #1 = { noreturn }
54attributes #2 = { nounwind }
55
56; EH: LLVM ERROR: Emscripten EH/SjLj does not support multivalue returns
57; SJLJ: LLVM ERROR: Emscripten EH/SjLj does not support multivalue returns
58