[llvm] [RISCV] Handle RVV return type in calling convention correctly (PR #87736)

Roger Ferrer Ibáñez via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 5 04:09:15 PDT 2024


================
@@ -21077,7 +21079,82 @@ unsigned RISCVTargetLowering::getMinimumJumpTableEntries() const {
   return Subtarget.getMinimumJumpTableEntries();
 }
 
-void RVVArgDispatcher::constructArgInfos(ArrayRef<Type *> TypeList) {
+// Handle single arg such as return value.
+template <typename Arg>
+void RVVArgDispatcher::constructArgInfos(ArrayRef<Arg> ArgList) {
+  // This lambda determines whether an array of types are constructed by
+  // homogeneous vector types.
+  auto isHomogeneousScalableVectorType = [&](ArrayRef<Arg> ArgList) {
+    // First, extract the first element in the argument type.
+    MVT FirstArgRegType;
+    unsigned FirstArgElements = 0;
+    typename SmallVectorImpl<Arg>::const_iterator It;
+    for (It = ArgList.begin(); It != ArgList.end(); ++It) {
+      FirstArgRegType = It->VT;
+      ++FirstArgElements;
+      if (!It->Flags.isSplit() || It->Flags.isSplitEnd())
+        break;
+    }
+    ++It;
----------------
rofirrim wrote:

I understand it will always hold that `It != ArgList.end()` here. I'd add an assert before the `It++`.

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


More information about the llvm-commits mailing list