Skip to content

Commit

Permalink
[WebAssembly] Move call_indirect_alloca to call.ll
Browse files Browse the repository at this point in the history
Not sure the distinction between `call.ll` and `call-indirect.ll`,
because `call.ll` also seems to contain many `call_indirect` tests. Also
before D147033 `call-indirect.ll` only contained a single test and it
also tests it with `obj2yaml`, so I guess that file was created for
testing functionalities for object files as well.

We can probably merge these two someday. But anyway, this moves
`call_indirect_alloca` I added in D147033 to `call.ll`, given that that
file contains more `call_indirect` tests and I'm planning to add more
`call_indirect` tests in a followup CL.

Reviewed By: tlively

Differential Revision: https://reviews.llvm.org/D147396
  • Loading branch information
aheejin committed Apr 5, 2023
1 parent 93c194f commit 47fc018
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
21 changes: 0 additions & 21 deletions llvm/test/CodeGen/WebAssembly/call-indirect.ll
Expand Up @@ -18,33 +18,12 @@ define void @call_indirect_void(ptr %callee) {
ret void
}

; CHECK-LABEL: call_indirect_alloca:
; CHECK-NEXT: .functype call_indirect_alloca () -> ()
; CHECK: local.tee 0
; CHECK-NEXT: global.set __stack_pointer
; CHECK-NEXT: local.get 0
; CHECK-NEXT: i32.const 12
; CHECK-NEXT: i32.add
; REF: call_indirect __indirect_function_table, () -> ()
; NOREF: call_indirect () -> ()
define void @call_indirect_alloca() {
entry:
%ptr = alloca i32, align 4
call void %ptr()
ret void
}

; OBJ: Imports:
; OBJ-NEXT: - Module: env
; OBJ-NEXT: Field: __linear_memory
; OBJ-NEXT: Kind: MEMORY
; OBJ-NEXT: Memory:
; OBJ-NEXT: Minimum: 0x0
; OBJ-NEXT: - Module: env
; OBJ-NEXT: Field: __stack_pointer
; OBJ-NEXT: Kind: GLOBAL
; OBJ-NEXT: GlobalType: I32
; OBJ-NEXT: GlobalMutable: true
; OBJ-NEXT: - Module: env
; OBJ-NEXT: Field: __indirect_function_table
; OBJ-NEXT: Kind: TABLE
15 changes: 15 additions & 0 deletions llvm/test/CodeGen/WebAssembly/call.ll
Expand Up @@ -236,6 +236,21 @@ bb2:
ret void
}

; Allocas should be lowered to call_indirects.
; CHECK-LABEL: call_indirect_alloca:
; CHECK: local.tee $push{{.*}}=, [[L0:[0-9]+]]
; CHECK-NEXT: global.set __stack_pointer
; CHECK-NEXT: local.get $push{{.*}}=, [[L0]]
; CHECK-NEXT: i32.const $push{{.*}}=, 12
; CHECK-NEXT: i32.add
; CHECK-NEXT: call_indirect $pop{{.*}}
define void @call_indirect_alloca() {
entry:
%ptr = alloca i32, align 4
call void %ptr()
ret void
}

; TODO: test the following:
; - More argument combinations.
; - Tail call.
Expand Down

0 comments on commit 47fc018

Please sign in to comment.