[llvm] [GISel][RISCV]Implement indirect parameter passing for large scalars (PR #95429)

Sergei Barannikov via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 14 06:16:15 PDT 2024


================
@@ -790,6 +805,62 @@ bool CallLowering::handleAssignments(ValueHandler &Handler,
       CCValAssign &VA = ArgLocs[j + Idx];
       const ISD::ArgFlagsTy Flags = Args[i].Flags[Part];
 
+      // We found an indirect parameter passing and we are at the first part of
+      // the value being passed. In this case copy the incoming pointer into a
+      // virtual register so later we can load it.
+      if (VA.getLocInfo() == CCValAssign::Indirect && Flags.isSplit()) {
+        IndirectParameterPassingHandled = true;
+        bool IsInStack = false;
+        Register PhysReg;
+        if (VA.isRegLoc()) {
+          PhysReg = VA.getLocReg();
+        } else if (VA.isMemLoc()) {
+          IsInStack = true;
+          LLT MemTy = Handler.getStackValueStoreType(DL, VA, Flags);
+          MachinePointerInfo MPO;
+          PhysReg = Handler.getStackAddress(
----------------
s-barannikov wrote:

This isn't right. getStackAddress returns a virtual register, and that shouldn't be passed to assignValueToReg. I guess this is how you get a virtual register in the live-ins list.
assignValueToReg should only be called if VA.isRegLoc() returns true.

I think that passing a pointer containing the address of an indirect object can be handled the same way as passing an ordinary pointer argument (one without the `Indirect` flag set). The `Indirect` flags only tells us that we should do some _additional_ work. I'd try to remove the `break` below and let the generic code handle the pointer.


https://github.com/llvm/llvm-project/pull/95429


More information about the llvm-commits mailing list