[llvm] [RISCV] Preserve call-preserved reg mask for LPAD-aligned calls (PR #210868)

Sam Elliott via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 20 23:15:32 PDT 2026


================
@@ -3236,12 +3236,22 @@ void RISCVDAGToDAGISel::Select(SDNode *Node) {
       LpadLabel = PreferredLandingPadLabel;
     }
 
-    SmallVector<SDValue, 4> Ops;
+    // Preserve the argument-register and register-mask operands (operands
+    // 2..N-2, between Callee and the optional glue) so the pseudo call
+    // still reports its call-preserved mask to the register allocator.
+    SmallVector<SDValue, 8> Ops;
     Ops.push_back(Node->getOperand(1));
     Ops.push_back(CurDAG->getTargetConstant(LpadLabel, DL, XLenVT));
+
+    unsigned NumOps = Node->getNumOperands();
+    bool HasGlue = Node->getGluedNode() != nullptr;
+    unsigned LastRegOperand = HasGlue ? NumOps - 1 : NumOps;
----------------
lenary wrote:

This needs a better name, as it's not the last one, it's one after the last reg operand

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


More information about the llvm-commits mailing list