[clang] [MS] Follow up fix to pass aligned args to variadic x86_32 functions (PR #65692)

John McCall via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 8 11:07:55 PDT 2023


================
@@ -812,11 +815,13 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, CCState &State,
     }
     llvm::IntegerType *PaddingType = NeedsPadding ? Int32 : nullptr;
 
-    // Pass over-aligned aggregates on Windows indirectly. This behavior was
-    // added in MSVC 2015. Use the required alignment from the record layout,
-    // since that may be less than the regular type alignment, and types with
-    // required alignment of less than 4 bytes are not passed indirectly.
-    if (IsWin32StructABI) {
+    // Pass over-aligned aggregates to non-variadic functions on Windows
+    // indirectly. This behavior was added in MSVC 2015. Use the required
+    // alignment from the record layout, since that may be less than the
+    // regular type alignment, and types with required alignment of less than 4
+    // bytes are not passed indirectly.
+    if (IsWin32StructABI && (!State.Required.allowsOptionalArgs() ||
+                             ArgIndex < State.Required.getNumRequiredArgs())) {
----------------
rjmccall wrote:

Minor request: please extract this second half into a helper function like `RequiredArgs::isRequiredArg(unsigned)`.

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


More information about the cfe-commits mailing list