1 ; RUN: opt < %s -wasm-lower-em-ehsjlj -enable-emscripten-sjlj -S | FileCheck %s
3 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
4 target triple = "wasm32-unknown-emscripten"
6 ; Tests if an alias to a function (here malloc) is correctly handled as a
7 ; function that cannot longjmp.
9 %struct.__jmp_buf_tag = type { [6 x i32], i32, [32 x i32] }
10 @malloc = weak alias ptr (i32), ptr @dlmalloc
12 ; CHECK-LABEL: @malloc_test
13 define void @malloc_test() {
16 %retval = alloca i32, align 4
17 %jmp = alloca [1 x %struct.__jmp_buf_tag], align 16
18 store i32 0, ptr %retval, align 4
19 %call = call i32 @setjmp(ptr %jmp) #0
24 ; This is a dummy dlmalloc implemenation only to make compiler pass, because an
25 ; alias (malloc) has to point an actual definition.
26 define ptr @dlmalloc(i32) {
27 %p = inttoptr i32 0 to ptr
32 ; Function Attrs: returns_twice
33 declare i32 @setjmp(ptr) #0
35 attributes #0 = { returns_twice }