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: %cmp = icmp eq ptr @foo, null
40 ; CHECK: br i1 %cmp, label %if.then, label %if.end
41 define i8 @null_compare() {
42 %cmp = icmp eq ptr @foo, null
43 br i1 %cmp, label %if.then, label %if.end
50 ; CHECK-LABEL: @as_paramater
51 ; CHECK: call void @func_param(ptr @foo)
52 define void @as_paramater() {
53 call void @func_param(ptr @foo)
57 ; Check if a sret parameter works in a no-prototype function.
58 ; CHECK-LABEL: @sret_param
59 ; CHECK: call void @make_struct_foo(ptr sret(%struct.foo) %foo)
60 %struct.foo = type { i32, i32 }
61 declare void @make_struct_foo(ptr sret(%struct.foo), ...) #1
62 define void @sret_param() {
63 %foo = alloca %struct.foo, align 4
64 call void @make_struct_foo(ptr sret(%struct.foo) %foo)
68 declare void @func_param(ptr)
70 ; CHECK: declare void @func_not_called()
71 declare void @func_not_called(...) #1
73 ; CHECK: declare extern_weak i64 @foo(i32)
74 declare extern_weak i64 @foo(...) #1
76 ; CHECK-NOT: attributes {{.*}} = { {{.*}}"no-prototype"{{.*}} }
77 attributes #1 = { "no-prototype" }