[clang] [CIR] Expand integer-aggregate va_arg on x86-64 (PR #201175)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 16 09:49:23 PDT 2026
================
@@ -0,0 +1,152 @@
+//===- X86.cpp - Emit CIR for x86-64 -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "../TargetLoweringInfo.h"
+#include "clang/CIR/Dialect/Builder/CIRBaseBuilder.h"
+#include "clang/CIR/Dialect/IR/CIRDataLayout.h"
+#include "clang/CIR/Dialect/IR/CIRDialect.h"
+#include "clang/CIR/Dialect/IR/CIROpsEnums.h"
+#include "clang/CIR/Dialect/IR/CIRTypes.h"
+
+#include <cstdint>
+
+namespace cir {
+
+namespace {
+
+/// x86-64 System V target hooks.
+class X86_64TargetLoweringInfo : public TargetLoweringInfo {
+public:
+ mlir::Value
+ lowerAggregateVAArg(CIRBaseBuilderTy &builder, cir::VAArgOp op,
+ mlir::Value valist,
+ const cir::CIRDataLayout &dataLayout) const override;
+};
+
+// Expand a `cir.va_arg` that produces an aggregate into the x86-64 System V
+// register-save-area dance. The generic lowering of `cir.va_arg` emits an
+// `llvm.va_arg` instruction, which Selection-DAG cannot handle for aggregate
+// types (it crashes with "Unknown type!"). Classic CodeGen open-codes this
+// expansion at the AST level; CIR defers it to the CXXABILowering pass so the
+// LLVM lowering only ever sees a fully expanded form.
+//
+// Only aggregates whose eightbytes are all of INTEGER class (integers,
----------------
adams381 wrote:
Agreed, belongs in CallConvLowering with the classifier, not here. Closing; I'll redo it on the callconv stack.
https://github.com/llvm/llvm-project/pull/201175
More information about the cfe-commits
mailing list