1; RUN: llvm-as %s -o %t.o
2; RUN: wasm-ld %t.o -o %t.wasm --allow-undefined
3; RUN: obj2yaml %t.wasm | FileCheck %s
4
5target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
6target triple = "wasm32-unknown-unknown"
7
8declare i32 @bar()
9
10; Symbols such as foo which are only called indirectly are handled slightly
11; differently with respect to signature checking.
12declare i32 @foo()
13
14@ptr = global i8* bitcast (i32 ()* @foo to i8*), align 8
15; Ensure access to ptr is not inlined below, even under LTO
16@llvm.used = appending global [1 x i8**] [i8** @ptr], section "llvm.metadata"
17
18define void @_start() {
19  call i32 @bar()
20
21  %addr = load i32 ()*, i32 ()** bitcast (i8** @ptr to i32 ()**), align 8
22  call i32 %addr()
23
24  ret void
25}
26
27; CHECK:       - Type:            IMPORT
28; CHECK-NEXT:    Imports:
29; CHECK-NEXT:      - Module:          env
30; CHECK-NEXT:        Field:           bar
31; CHECK-NEXT:        Kind:            FUNCTION
32; CHECK-NEXT:        SigIndex:        0
33; CHECK-NEXT:      - Module:          env
34; CHECK-NEXT:        Field:           foo
35; CHECK-NEXT:        Kind:            FUNCTION
36; CHECK-NEXT:        SigIndex:        0
37