1 ; RUN: opt -S -wasm-add-missing-prototypes %s | FileCheck %s
3 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
4 target triple = "wasm32-unknown-unknown"
6 ; CHECK: @foo_addr = global ptr @foo, align 8
7 @foo_addr = global ptr @foo, align 8
9 ; CHECK: @foo_addr_i8 = global ptr @foo, align 8
10 @foo_addr_i8 = global ptr @foo, align 8
12 ; CHECK-LABEL: @call_foo
13 ; CHECK: %call = call i64 @foo(i32 42)
14 define void @call_foo(i32 %a) {
15 %call = call i64 @foo(i32 42)
19 ; CHECK-LABEL: @call_foo_ptr
20 ; CHECK-NEXT: %call = call i64 @foo(i32 43)
21 define i64 @call_foo_ptr(i32 %a) {
22 %call = call i64 (i32) @foo(i32 43)
26 ; CHECK-LABEL: @to_intptr_inst
27 ; CHECK-NEXT: ret ptr @foo
28 define ptr @to_intptr_inst() {
32 ; CHECK-LABEL: @to_intptr_constexpr
34 define ptr @to_intptr_constexpr() {
38 ; CHECK-LABEL: @null_compare
39 ; CHECK: br i1 icmp eq (ptr @foo, ptr null), label %if.then, label %if.end
40 define i8 @null_compare() {
41 br i1 icmp eq (ptr @foo, ptr null), label %if.then, label %if.end
48 ; CHECK-LABEL: @as_paramater
49 ; CHECK: call void @func_param(ptr @foo)
50 define void @as_paramater() {
51 call void @func_param(ptr @foo)
55 ; Check if a sret parameter works in a no-prototype function.
56 ; CHECK-LABEL: @sret_param
57 ; CHECK: call void @make_struct_foo(ptr sret(%struct.foo) %foo)
58 %struct.foo = type { i32, i32 }
59 declare void @make_struct_foo(ptr sret(%struct.foo), ...) #1
60 define void @sret_param() {
61 %foo = alloca %struct.foo, align 4
62 call void @make_struct_foo(ptr sret(%struct.foo) %foo)
66 declare void @func_param(ptr)
68 ; CHECK: declare void @func_not_called()
69 declare void @func_not_called(...) #1
71 ; CHECK: declare extern_weak i64 @foo(i32)
72 declare extern_weak i64 @foo(...) #1
74 ; CHECK-NOT: attributes {{.*}} = { {{.*}}"no-prototype"{{.*}} }
75 attributes #1 = { "no-prototype" }