[PATCH] D147033: [WebAssembly] Select call_indirect for alloca calls

Heejin Ahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 29 12:47:19 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd91c9aef9b37: [WebAssembly] Select call_indirect for alloca calls (authored by aheejin).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147033/new/

https://reviews.llvm.org/D147033

Files:
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/test/CodeGen/WebAssembly/call-indirect.ll


Index: llvm/test/CodeGen/WebAssembly/call-indirect.ll
===================================================================
--- llvm/test/CodeGen/WebAssembly/call-indirect.ll
+++ llvm/test/CodeGen/WebAssembly/call-indirect.ll
@@ -18,6 +18,22 @@
   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
@@ -25,5 +41,10 @@
 ; 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
Index: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
===================================================================
--- llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
@@ -534,11 +534,12 @@
   assert(CallResults.getOpcode() == WebAssembly::CALL_RESULTS ||
          CallResults.getOpcode() == WebAssembly::RET_CALL_RESULTS);
 
-  bool IsIndirect = CallParams.getOperand(0).isReg();
+  bool IsIndirect =
+      CallParams.getOperand(0).isReg() || CallParams.getOperand(0).isFI();
   bool IsRetCall = CallResults.getOpcode() == WebAssembly::RET_CALL_RESULTS;
 
   bool IsFuncrefCall = false;
-  if (IsIndirect) {
+  if (IsIndirect && CallParams.getOperand(0).isReg()) {
     Register Reg = CallParams.getOperand(0).getReg();
     const MachineFunction *MF = BB->getParent();
     const MachineRegisterInfo &MRI = MF->getRegInfo();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147033.509445.patch
Type: text/x-patch
Size: 2205 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230329/06c684c3/attachment.bin>


More information about the llvm-commits mailing list