36 lines · plain
1; RUN: opt < %s -wasm-lower-em-ehsjlj -enable-emscripten-sjlj -S | FileCheck %s2 3target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"4target triple = "wasm32-unknown-emscripten"5 6; Tests if an alias to a function (here malloc) is correctly handled as a7; function that cannot longjmp.8 9%struct.__jmp_buf_tag = type { [6 x i32], i32, [32 x i32] }10@malloc = weak alias ptr (i32), ptr @dlmalloc11 12; CHECK-LABEL: @malloc_test13define void @malloc_test() {14entry:15 ; CHECK: alloca i3216 %retval = alloca i32, align 417 %jmp = alloca [1 x %struct.__jmp_buf_tag], align 1618 store i32 0, ptr %retval, align 419 %call = call i32 @setjmp(ptr %jmp) #020 call void @foo()21 ret void22}23 24; This is a dummy dlmalloc implemenation only to make compiler pass, because an25; alias (malloc) has to point an actual definition.26define ptr @dlmalloc(i32) {27 %p = inttoptr i32 0 to ptr28 ret ptr %p29}30 31declare void @foo()32; Function Attrs: returns_twice33declare i32 @setjmp(ptr) #034 35attributes #0 = { returns_twice }36