[clang] [clang][CodeGen][MSVC] Return vector types from methods indirectly (PR #157365)

Mariya Podchishchaeva via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 8 01:13:30 PDT 2025


================
@@ -1168,15 +1168,20 @@ static bool isTrivialForMSVC(const CXXRecordDecl *RD, QualType Ty,
 }
 
 bool MicrosoftCXXABI::classifyReturnType(CGFunctionInfo &FI) const {
-  const CXXRecordDecl *RD = FI.getReturnType()->getAsCXXRecordDecl();
-  if (!RD)
-    return false;
-
-  bool isTrivialForABI = RD->canPassInRegisters() &&
-                         isTrivialForMSVC(RD, FI.getReturnType(), CGM);
-
-  // MSVC always returns structs indirectly from C++ instance methods.
-  bool isIndirectReturn = !isTrivialForABI || FI.isInstanceMethod();
+  bool isIndirectReturn = false;
+  if (const CXXRecordDecl *RD = FI.getReturnType()->getAsCXXRecordDecl()) {
+    bool isTrivialForABI = RD->canPassInRegisters() &&
+                           isTrivialForMSVC(RD, FI.getReturnType(), CGM);
+
+    // MSVC always returns structs indirectly from C++ instance methods.
+    isIndirectReturn = !isTrivialForABI || FI.isInstanceMethod();
+  } else if (isa<VectorType>(FI.getReturnType())) {
----------------
Fznamznon wrote:

Not sure if `FI.getReturnType()` already has a canonical type, but I would suggest doing 
```suggestion
  } else if (FI.getReturnType()->isVectorType()) {
```
in case it doesn't

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


More information about the cfe-commits mailing list