https://github.com/skc7 updated https://github.com/llvm/llvm-project/pull/220579

>From 8a512d66582c61547659896cb15979f90b9f0808 Mon Sep 17 00:00:00 2001
From: skc7 <[email protected]>
Date: Wed, 16 Sep 2026 10:24:00 +0530
Subject: [PATCH] [CIR][ABI] Honor abi::ArgInfo::CanBeFlattened in the
 call-conv lowering

---
 .../CIR/Dialect/Transforms/CallConvLoweringPass.cpp  | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/clang/lib/CIR/Dialect/Transforms/CallConvLoweringPass.cpp 
b/clang/lib/CIR/Dialect/Transforms/CallConvLoweringPass.cpp
index f51ee6f9169a3..4310466ac5841 100644
--- a/clang/lib/CIR/Dialect/Transforms/CallConvLoweringPass.cpp
+++ b/clang/lib/CIR/Dialect/Transforms/CallConvLoweringPass.cpp
@@ -538,9 +538,10 @@ static const llvm::abi::Type *mapCIRType(mlir::Type type,
 /// unpacked into the register(s) holding it, a scalar too wide for one 
register
 /// split into a tuple of them, a scalar the classifier widens to fill its
 /// eightbyte, and a value whose live bytes start partway into its storage
-/// because a leading eightbyte holds no field (getDirectOffset).  getDirect
-/// keeps canFlatten set so the rewriter can split a multi-field coerced
-/// struct into individual wire arguments.  Any other scalar passes in its
+/// because a leading eightbyte holds no field (getDirectOffset).  canFlatten
+/// follows the classifier's CanBeFlattened, so the rewriter splits a
+/// multi-field coerced struct into individual wire arguments unless the
+/// classifier asked to keep it intact.  Any other scalar passes in its
 /// natural CIR type, which a null coercion denotes.  A coercion this bridge
 /// cannot represent yields std::nullopt so the caller reports NYI rather than
 /// silently passing the value unchanged.
@@ -601,7 +602,10 @@ convertABIArgInfo(const llvm::abi::ArgInfo &info, 
MLIRContext *ctx,
     // trip for nothing.
     if (comparesAgainstCoerce && coerced == origTy)
       return ArgClassification::getDirect();
-    return ArgClassification::getDirect(coerced, offset);
+    ArgClassification classified =
+        ArgClassification::getDirect(coerced, offset);
+    classified.canFlatten = info.getCanBeFlattened();
+    return classified;
   }
   // An extended value is always read from byte 0 of its own storage, so
   // there is no offset to honor here.

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to