https://github.com/R-Goc updated 
https://github.com/llvm/llvm-project/pull/221038

>From 30f36a487b73b0e0cd9505e2e682e1711e45def8 Mon Sep 17 00:00:00 2001
From: R-Goc <[email protected]>
Date: Thu, 3 Sep 2026 22:43:20 +0200
Subject: [PATCH 1/5] [CIR] Add initial Microsoft C++ ABI skeleton in ClangIR

Introduce the initial skeleton for the Microsoft C++ ABI in ClangIR
CodeGen and TargetLowering:
- Implement CIRGenMicrosoftCXXABI stub class in CodeGen deriving from
  CIRGenCXXABI, with all virtual methods stubbed out with Not-Yet-Implemented
  (NYI) diagnostics or conservative defaults.
- Implement LowerMicrosoftCXXABI stub class in TargetLowering deriving
  from CIRCXXABI.
- Wire up TargetCXXABI::Microsoft dispatch in CIRGenModule and LowerModule.
- Add cxx-msvc-abi.cpp lit test verifying that compiling with triple
  x86_64-pc-windows-msvc initializes the ABI without crashing.

Assisted-by: Gemini:gemini-3.8-flash-high
---
 clang/lib/CIR/CodeGen/CIRGenCXXABI.h          |   3 +
 .../lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp | 285 ++++++++++++++++++
 clang/lib/CIR/CodeGen/CIRGenModule.cpp        |   3 +-
 clang/lib/CIR/CodeGen/CMakeLists.txt          |   1 +
 .../Transforms/TargetLowering/CIRCXXABI.h     |   3 +
 .../Transforms/TargetLowering/CMakeLists.txt  |   1 +
 .../TargetLowering/LowerMicrosoftCXXABI.cpp   | 158 ++++++++++
 .../Transforms/TargetLowering/LowerModule.cpp |   2 +-
 clang/test/CIR/CodeGen/cxx-msvc-abi.cpp       |   6 +
 9 files changed, 460 insertions(+), 2 deletions(-)
 create mode 100644 clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp
 create mode 100644 
clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerMicrosoftCXXABI.cpp
 create mode 100644 clang/test/CIR/CodeGen/cxx-msvc-abi.cpp

diff --git a/clang/lib/CIR/CodeGen/CIRGenCXXABI.h 
b/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
index bb100f7afd929..85cf647bf451c 100644
--- a/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
+++ b/clang/lib/CIR/CodeGen/CIRGenCXXABI.h
@@ -391,6 +391,9 @@ class CIRGenCXXABI {
 /// Creates and Itanium-family ABI
 CIRGenCXXABI *CreateCIRGenItaniumCXXABI(CIRGenModule &cgm);
 
+/// Creates Microsoft ABI
+CIRGenCXXABI *CreateCIRGenMicrosoftCXXABI(CIRGenModule &cgm);
+
 } // namespace clang::CIRGen
 
 #endif
diff --git a/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp 
b/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp
new file mode 100644
index 0000000000000..f30d9c4b984a9
--- /dev/null
+++ b/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp
@@ -0,0 +1,285 @@
+//===--- CIRGenMicrosoftCXXABI.cpp - Emit CIR Code for MS C++ ABI --------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This provides C++ code generation targeting the Microsoft C++ ABI.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CIRGenCXXABI.h"
+#include "CIRGenFunction.h"
+#include "CIRGenModule.h"
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Mangle.h"
+
+using namespace clang;
+using namespace clang::CIRGen;
+
+namespace {
+
+class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
+public:
+  CIRGenMicrosoftCXXABI(CIRGenModule &cgm) : CIRGenCXXABI(cgm) {}
+
+  AddedStructorArgCounts
+  buildStructorSignature(GlobalDecl gd,
+                         llvm::SmallVectorImpl<CanQualType> &argTys) override {
+    return AddedStructorArgCounts{};
+  }
+
+  void addImplicitStructorParams(CIRGenFunction &cgf, QualType &resTy,
+                                 FunctionArgList &params) override {}
+
+  void emitInstanceFunctionProlog(SourceLocation loc,
+                                  CIRGenFunction &cgf) override {}
+
+  AddedStructorArgs getImplicitConstructorArgs(CIRGenFunction &cgf,
+                                               const CXXConstructorDecl *d,
+                                               CXXCtorType type,
+                                               bool forVirtualBase,
+                                               bool delegating) override {
+    return AddedStructorArgs{};
+  }
+
+  mlir::Value getCXXDestructorImplicitParam(CIRGenFunction &cgf,
+                                            const CXXDestructorDecl *dd,
+                                            CXXDtorType type,
+                                            bool forVirtualBase,
+                                            bool delegating) override {
+    return nullptr;
+  }
+
+  void emitCXXConstructors(const CXXConstructorDecl *d) override {
+    cgm.errorNYI(d->getSourceRange(), "emitCXXConstructors: MSVC ABI");
+  }
+
+  void emitCXXDestructors(const CXXDestructorDecl *d) override {
+    cgm.errorNYI(d->getSourceRange(), "emitCXXDestructors: MSVC ABI");
+  }
+
+  void emitCXXStructor(GlobalDecl gd) override {
+    cgm.errorNYI(gd.getDecl()->getSourceRange(), "emitCXXStructor: MSVC ABI");
+  }
+
+  void emitDestructorCall(CIRGenFunction &cgf, const CXXDestructorDecl *dd,
+                          CXXDtorType type, bool forVirtualBase,
+                          bool delegating, Address thisAddr,
+                          QualType thisTy) override {
+    cgf.cgm.errorNYI(dd->getSourceRange(), "emitDestructorCall: MSVC ABI");
+  }
+
+  mlir::Value emitVirtualDestructorCall(CIRGenFunction &cgf,
+                                        const CXXDestructorDecl *dtor,
+                                        CXXDtorType dtorType, Address thisAddr,
+                                        DeleteOrMemberCallExpr e) override {
+    cgf.cgm.errorNYI(dtor->getSourceRange(),
+                     "emitVirtualDestructorCall: MSVC ABI");
+    return nullptr;
+  }
+
+  void emitVirtualObjectDelete(CIRGenFunction &cgf, const CXXDeleteExpr *de,
+                               Address ptr, QualType elementType,
+                               const CXXDestructorDecl *dtor) override {
+    cgf.cgm.errorNYI(de->getSourceRange(), "emitVirtualObjectDelete: MSVC 
ABI");
+  }
+
+  const CXXRecordDecl *
+  getThisArgumentTypeForMethod(const CXXMethodDecl *md) override {
+    return md->getParent();
+  }
+
+  Address adjustThisArgumentForVirtualFunctionCall(CIRGenFunction &cgf,
+                                                   GlobalDecl gd,
+                                                   Address thisAddr,
+                                                   bool virtualCall) override {
+    return thisAddr;
+  }
+
+  bool isVirtualOffsetNeededForVTableField(CIRGenFunction &cgf,
+                                           CIRGenFunction::VPtr vptr) override 
{
+    return false;
+  }
+
+  cir::GlobalOp getAddrOfVTable(const CXXRecordDecl *rd,
+                                CharUnits vptrOffset) override {
+    cgm.errorNYI(rd->getSourceRange(), "getAddrOfVTable: MSVC ABI");
+    return nullptr;
+  }
+
+  mlir::Value getVTableAddressPoint(BaseSubobject base,
+                                    const CXXRecordDecl *vtableClass) override 
{
+    cgm.errorNYI(vtableClass->getSourceRange(),
+                 "getVTableAddressPoint: MSVC ABI");
+    return nullptr;
+  }
+
+  mlir::Value getVTableAddressPointInStructor(
+      CIRGenFunction &cgf, const CXXRecordDecl *vtableClass, BaseSubobject 
base,
+      const CXXRecordDecl *nearestVBase) override {
+    cgf.cgm.errorNYI(vtableClass->getSourceRange(),
+                     "getVTableAddressPointInStructor: MSVC ABI");
+    return nullptr;
+  }
+
+  CIRGenCallee getVirtualFunctionPointer(CIRGenFunction &cgf, GlobalDecl gd,
+                                         Address thisAddr, mlir::Type ty,
+                                         SourceLocation loc) override {
+    cgf.cgm.errorNYI(loc, "getVirtualFunctionPointer: MSVC ABI");
+    return CIRGenCallee();
+  }
+
+  void emitVTableDefinitions(CIRGenVTables &cgvt,
+                             const CXXRecordDecl *rd) override {
+    cgm.errorNYI(rd->getSourceRange(), "emitVTableDefinitions: MSVC ABI");
+  }
+
+  void emitVirtualInheritanceTables(const CXXRecordDecl *rd) override {
+    if (rd->getNumVBases())
+      cgm.errorNYI(rd->getSourceRange(),
+                   "emitVirtualInheritanceTables: MSVC VBTables");
+  }
+
+  void
+  initializeHiddenVirtualInheritanceMembers(CIRGenFunction &cgf,
+                                            const CXXRecordDecl *rd) override {
+    if (rd->getNumVBases())
+      cgf.cgm.errorNYI(rd->getSourceRange(),
+                       "initializeHiddenVirtualInheritanceMembers: vbptr 
stores");
+  }
+
+  mlir::Value
+  getVirtualBaseClassOffset(mlir::Location loc, CIRGenFunction &cgf,
+                            Address thisAddr, const CXXRecordDecl *classDecl,
+                            const CXXRecordDecl *baseClassDecl) override {
+    cgf.cgm.errorNYI(loc, "getVirtualBaseClassOffset: MSVC ABI");
+    return nullptr;
+  }
+
+  cir::MethodAttr buildVirtualMethodAttr(cir::MethodType methodTy,
+                                         const CXXMethodDecl *md) override {
+    cgm.errorNYI(md->getSourceRange(), "buildVirtualMethodAttr: MSVC ABI");
+    return cir::MethodAttr();
+  }
+
+  mlir::Value performThisAdjustment(CIRGenFunction &cgf, Address thisAddr,
+                                    const CXXRecordDecl *unadjustedClass,
+                                    const ThunkInfo &ti) override {
+    return thisAddr.emitRawPointer();
+  }
+
+  mlir::Value performReturnAdjustment(CIRGenFunction &cgf, Address ret,
+                                      const CXXRecordDecl *unadjustedClass,
+                                      const ReturnAdjustment &ra) override {
+    return ret.emitRawPointer();
+  }
+
+  bool canSpeculativelyEmitVTable(const CXXRecordDecl *rd) const override {
+    return false;
+  }
+
+  bool doStructorsInitializeVPtrs(const CXXRecordDecl *vtableClass) override {
+    return false;
+  }
+
+  bool exportThunk() override { return false; }
+
+  bool useThunkForDtorVariant(const CXXDestructorDecl *dtor,
+                              CXXDtorType dt) const override {
+    return false;
+  }
+
+  void setThunkLinkage(cir::FuncOp thunk, bool forVTable, GlobalDecl gd,
+                       bool returnAdjustment) override {
+    thunk.setLinkage(cir::GlobalLinkageKind::LinkOnceODRLinkage);
+  }
+
+  llvm::StringRef getPureVirtualCallName() override { return "_purecall"; }
+  llvm::StringRef getDeletedVirtualCallName() override { return "_purecall"; }
+
+  bool isZeroInitializable(const MemberPointerType *mpt) override {
+    return true;
+  }
+
+  bool requiresArrayCookie(const CXXNewExpr *e) override {
+    return false;
+  }
+
+  CharUnits getArrayCookieSizeImpl(QualType elementType) override {
+    return CharUnits::Zero();
+  }
+
+  Address initializeArrayCookie(CIRGenFunction &cgf, Address newPtr,
+                                mlir::Value numElements, const CXXNewExpr *e,
+                                QualType elementType) override {
+    cgf.cgm.errorNYI(e->getSourceRange(), "initializeArrayCookie: MSVC ABI");
+    return newPtr;
+  }
+
+  bool shouldTypeidBeNullChecked(QualType srcTy) override {
+    return false;
+  }
+
+  mlir::Value emitTypeid(CIRGenFunction &cgf, QualType srcTy, Address thisPtr,
+                         mlir::Type typeInfoPtrTy) override {
+    cgf.cgm.errorNYI(cgf.getLoc(srcTy->getAsCXXRecordDecl()->getLocation()),
+                     "emitTypeid: MSVC ABI");
+    return cgf.getBuilder().getNullPtr(
+        typeInfoPtrTy, cgf.getLoc(srcTy->getAsCXXRecordDecl()->getLocation()));
+  }
+
+  void emitBadTypeidCall(CIRGenFunction &cgf, mlir::Location loc) override {
+    cgf.cgm.errorNYI(loc, "emitBadTypeidCall: MSVC ABI");
+  }
+
+  void emitBadCastCall(CIRGenFunction &cgf, mlir::Location loc) override {
+    cgm.errorNYI(loc, "emitBadCastCall: MSVC ABI");
+  }
+
+  mlir::Value emitDynamicCast(CIRGenFunction &cgf, mlir::Location loc,
+                              QualType srcRecordTy, QualType destRecordTy,
+                              cir::PointerType destCIRTy, bool isRefCast,
+                              Address src) override {
+    cgf.cgm.errorNYI(loc, "emitDynamicCast: MSVC ABI");
+    return cgf.getBuilder().getNullPtr(destCIRTy, loc);
+  }
+
+  mlir::Attribute getAddrOfRTTIDescriptor(mlir::Location loc,
+                                         QualType ty) override {
+    cgm.errorNYI(loc, "getAddrOfRTTIDescriptor: MSVC ABI");
+    return nullptr;
+  }
+
+  CatchTypeInfo getCatchAllTypeInfo() override {
+    return CatchTypeInfo{nullptr, 0};
+  }
+
+  CatchTypeInfo
+  getAddrOfCXXCatchHandlerType(mlir::Location loc, QualType ty,
+                               QualType catchHandlerType) override {
+    cgm.errorNYI(loc, "getAddrOfCXXCatchHandlerType: MSVC ABI");
+    return CatchTypeInfo{nullptr, 0};
+  }
+
+  void emitRethrow(CIRGenFunction &cgf, bool isNoReturn) override {
+    cgm.errorNYI("emitRethrow: MSVC ABI");
+  }
+
+  void emitThrow(CIRGenFunction &cgf, const CXXThrowExpr *e) override {
+    cgf.cgm.errorNYI(e->getSourceRange(), "emitThrow: MSVC ABI");
+  }
+
+  void registerGlobalDtor(const VarDecl *vd, cir::FuncOp dtor,
+                          mlir::Value addr) override {}
+};
+
+} // namespace
+
+CIRGenCXXABI *clang::CIRGen::CreateCIRGenMicrosoftCXXABI(CIRGenModule &cgm) {
+  return new CIRGenMicrosoftCXXABI(cgm);
+}
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index bdc2707723283..301257ca0d777 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -65,6 +65,8 @@ static CIRGenCXXABI *createCXXABI(CIRGenModule &cgm) {
   case TargetCXXABI::AppleARM64:
   case TargetCXXABI::GenericARM:
     return CreateCIRGenItaniumCXXABI(cgm);
+  case TargetCXXABI::Microsoft:
+    return CreateCIRGenMicrosoftCXXABI(cgm);
 
   case TargetCXXABI::Fuchsia:
   case TargetCXXABI::iOS:
@@ -72,7 +74,6 @@ static CIRGenCXXABI *createCXXABI(CIRGenModule &cgm) {
   case TargetCXXABI::GenericMIPS:
   case TargetCXXABI::WebAssembly:
   case TargetCXXABI::XL:
-  case TargetCXXABI::Microsoft:
     cgm.errorNYI("createCXXABI: C++ ABI kind");
     return nullptr;
   }
diff --git a/clang/lib/CIR/CodeGen/CMakeLists.txt 
b/clang/lib/CIR/CodeGen/CMakeLists.txt
index c4bd520fc61b7..1b5c0b91b394e 100644
--- a/clang/lib/CIR/CodeGen/CMakeLists.txt
+++ b/clang/lib/CIR/CodeGen/CMakeLists.txt
@@ -39,6 +39,7 @@ add_clang_library(clangCIR
   CIRGenExprScalar.cpp
   CIRGenFunction.cpp
   CIRGenItaniumCXXABI.cpp
+  CIRGenMicrosoftCXXABI.cpp
   CIRGenModule.cpp
   CIRGenOpenACC.cpp
   CIRGenOpenACCClause.cpp
diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRCXXABI.h 
b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRCXXABI.h
index 5c5d6421aea71..1f65c871d8315 100644
--- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRCXXABI.h
+++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CIRCXXABI.h
@@ -172,6 +172,9 @@ class CIRCXXABI {
 /// Creates an Itanium-family ABI.
 std::unique_ptr<CIRCXXABI> createItaniumCXXABI(LowerModule &lm);
 
+/// Creates a Microsoft-family ABI.
+std::unique_ptr<CIRCXXABI> createMicrosoftCXXABI(LowerModule &lm);
+
 } // namespace cir
 
 #endif // CLANG_LIB_CIR_DIALECT_TRANSFORMS_TARGETLOWERING_CIRCXXABI_H
diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/CMakeLists.txt 
b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CMakeLists.txt
index 81cc336699391..8a92bee9a6187 100644
--- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/CMakeLists.txt
+++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/CMakeLists.txt
@@ -3,6 +3,7 @@ add_clang_library(MLIRCIRTargetLowering
   CIRCXXABI.cpp
   LowerModule.cpp
   LowerItaniumCXXABI.cpp
+  LowerMicrosoftCXXABI.cpp
   TargetLoweringInfo.cpp
   Targets/AMDGPU.cpp
   Targets/NVPTX.cpp
diff --git 
a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerMicrosoftCXXABI.cpp 
b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerMicrosoftCXXABI.cpp
new file mode 100644
index 0000000000000..f670981453bed
--- /dev/null
+++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerMicrosoftCXXABI.cpp
@@ -0,0 +1,158 @@
+//===---- LowerMicrosoftCXXABI.cpp - Emit CIR for Microsoft-specific code 
-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This provides CIR lowering logic targeting the Microsoft C++ ABI.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CIRCXXABI.h"
+#include "LowerModule.h"
+#include "llvm/Support/ErrorHandling.h"
+
+namespace cir {
+
+namespace {
+
+class LowerMicrosoftCXXABI : public CIRCXXABI {
+public:
+  LowerMicrosoftCXXABI(LowerModule &lm) : CIRCXXABI(lm) {}
+
+  mlir::Type
+  lowerDataMemberType(cir::DataMemberType type,
+                      const mlir::TypeConverter &typeConverter) const override 
{
+    llvm_unreachable("Microsoft ABI member pointer lowering NYI");
+  }
+
+  mlir::Type
+  lowerMethodType(cir::MethodType type,
+                  const mlir::TypeConverter &typeConverter) const override {
+    llvm_unreachable("Microsoft ABI method pointer lowering NYI");
+  }
+
+  mlir::TypedAttr lowerDataMemberConstant(
+      cir::DataMemberAttr attr, const mlir::DataLayout &layout,
+      const mlir::TypeConverter &typeConverter) const override {
+    llvm_unreachable("Microsoft ABI member pointer lowering NYI");
+  }
+
+  mlir::TypedAttr lowerDataMemberOffsetConstant(
+      cir::DataMemberOffsetAttr attr, const mlir::DataLayout &layout,
+      const mlir::TypeConverter &typeConverter) const override {
+    llvm_unreachable("Microsoft ABI member pointer lowering NYI");
+  }
+
+  mlir::TypedAttr
+  lowerMethodConstant(cir::MethodAttr attr, const mlir::DataLayout &layout,
+                      const mlir::TypeConverter &typeConverter) const override 
{
+    llvm_unreachable("Microsoft ABI method pointer lowering NYI");
+  }
+
+  mlir::Operation *
+  lowerGetRuntimeMember(cir::GetRuntimeMemberOp op, mlir::Type loweredResultTy,
+                        mlir::Value loweredAddr, mlir::Value loweredMember,
+                        mlir::OpBuilder &builder) const override {
+    llvm_unreachable("Microsoft ABI member pointer lowering NYI");
+  }
+
+  void
+  lowerGetMethod(cir::GetMethodOp op, mlir::Value &callee, mlir::Value 
&thisArg,
+                 mlir::Value loweredMethod, mlir::Value loweredObjectPtr,
+                 mlir::ConversionPatternRewriter &rewriter) const override {
+    llvm_unreachable("Microsoft ABI method pointer lowering NYI");
+  }
+
+  mlir::Value lowerBaseDataMember(cir::BaseDataMemberOp op,
+                                  mlir::Value loweredSrc,
+                                  mlir::OpBuilder &builder) const override {
+    llvm_unreachable("Microsoft ABI member pointer lowering NYI");
+  }
+
+  mlir::Value lowerDerivedDataMember(cir::DerivedDataMemberOp op,
+                                     mlir::Value loweredSrc,
+                                     mlir::OpBuilder &builder) const override {
+    llvm_unreachable("Microsoft ABI member pointer lowering NYI");
+  }
+
+  mlir::Value lowerBaseMethod(cir::BaseMethodOp op, mlir::Value loweredSrc,
+                              mlir::OpBuilder &builder) const override {
+    llvm_unreachable("Microsoft ABI method pointer lowering NYI");
+  }
+
+  mlir::Value lowerDerivedMethod(cir::DerivedMethodOp op,
+                                 mlir::Value loweredSrc,
+                                 mlir::OpBuilder &builder) const override {
+    llvm_unreachable("Microsoft ABI method pointer lowering NYI");
+  }
+
+  mlir::Value lowerDataMemberCmp(cir::CmpOp op, mlir::Value loweredLhs,
+                                 mlir::Value loweredRhs,
+                                 mlir::OpBuilder &builder) const override {
+    llvm_unreachable("Microsoft ABI member pointer lowering NYI");
+  }
+
+  mlir::Value lowerMethodCmp(cir::CmpOp op, mlir::Value loweredLhs,
+                             mlir::Value loweredRhs,
+                             mlir::OpBuilder &builder) const override {
+    llvm_unreachable("Microsoft ABI method pointer lowering NYI");
+  }
+
+  mlir::Value lowerDataMemberBitcast(cir::CastOp op, mlir::Type loweredDstTy,
+                                     mlir::Value loweredSrc,
+                                     mlir::OpBuilder &builder) const override {
+    llvm_unreachable("Microsoft ABI member pointer lowering NYI");
+  }
+
+  mlir::Value
+  lowerDataMemberToBoolCast(cir::CastOp op, mlir::Value loweredSrc,
+                            mlir::OpBuilder &builder) const override {
+    llvm_unreachable("Microsoft ABI member pointer lowering NYI");
+  }
+
+  mlir::Value lowerMethodBitcast(cir::CastOp op, mlir::Type loweredDstTy,
+                                 mlir::Value loweredSrc,
+                                 mlir::OpBuilder &builder) const override {
+    llvm_unreachable("Microsoft ABI method pointer lowering NYI");
+  }
+
+  mlir::Value lowerMethodToBoolCast(cir::CastOp op, mlir::Value loweredSrc,
+                                    mlir::OpBuilder &builder) const override {
+    llvm_unreachable("Microsoft ABI method pointer lowering NYI");
+  }
+
+  mlir::Value lowerDynamicCast(cir::DynamicCastOp op,
+                               mlir::OpBuilder &builder) const override {
+    llvm_unreachable("Microsoft ABI dynamic cast lowering NYI");
+  }
+
+  mlir::Value lowerVTableGetTypeInfo(cir::VTableGetTypeInfoOp op,
+                                     mlir::OpBuilder &builder) const override {
+    llvm_unreachable("Microsoft ABI vtable get type info lowering NYI");
+  }
+
+  clang::CharUnits
+  getArrayCookieSizeImpl(mlir::Type elementType,
+                         const mlir::DataLayout &dataLayout) const override {
+    llvm_unreachable("Microsoft ABI array cookie lowering NYI");
+  }
+
+  mlir::Value readArrayCookieImpl(mlir::Location loc, mlir::Value allocPtr,
+                                  clang::CharUnits cookieSize,
+                                  clang::CharUnits cookieAlignment,
+                                  const mlir::DataLayout &dataLayout,
+                                  CIRBaseBuilderTy &builder) const override {
+    llvm_unreachable("Microsoft ABI array cookie lowering NYI");
+  }
+};
+
+} // namespace
+
+std::unique_ptr<CIRCXXABI> createMicrosoftCXXABI(LowerModule &lm) {
+  return std::make_unique<LowerMicrosoftCXXABI>(lm);
+}
+
+} // namespace cir
diff --git a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerModule.cpp 
b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerModule.cpp
index 5fd5c8c429f48..8ed0fb5b2cd26 100644
--- a/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerModule.cpp
+++ b/clang/lib/CIR/Dialect/Transforms/TargetLowering/LowerModule.cpp
@@ -37,7 +37,7 @@ static std::unique_ptr<CIRCXXABI> createCXXABI(LowerModule 
&lm) {
   case clang::TargetCXXABI::XL:
     return createItaniumCXXABI(lm);
   case clang::TargetCXXABI::Microsoft:
-    llvm_unreachable("Windows ABI NYI");
+    return createMicrosoftCXXABI(lm);
   }
 
   llvm_unreachable("invalid C++ ABI kind");
diff --git a/clang/test/CIR/CodeGen/cxx-msvc-abi.cpp 
b/clang/test/CIR/CodeGen/cxx-msvc-abi.cpp
new file mode 100644
index 0000000000000..e1a4d7519f5d4
--- /dev/null
+++ b/clang/test/CIR/CodeGen/cxx-msvc-abi.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -std=c++17 -fclangir 
-emit-cir %s -o %t.cir
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+
+void empty() {}
+
+// CIR: cir.func {{.*}} @"?empty@@YAXXZ"()

>From f65bf5cba2e704a55614427aaac2742ae8793b99 Mon Sep 17 00:00:00 2001
From: R-Goc <[email protected]>
Date: Thu, 3 Sep 2026 22:46:49 +0200
Subject: [PATCH 2/5] run clang-format

---
 .../lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp | 567 +++++++++---------
 1 file changed, 282 insertions(+), 285 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp 
b/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp
index f30d9c4b984a9..9e5faa5b5e54d 100644
--- a/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp
@@ -1,285 +1,282 @@
-//===--- CIRGenMicrosoftCXXABI.cpp - Emit CIR Code for MS C++ ABI --------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-//
-// This provides C++ code generation targeting the Microsoft C++ ABI.
-//
-//===----------------------------------------------------------------------===//
-
-#include "CIRGenCXXABI.h"
-#include "CIRGenFunction.h"
-#include "CIRGenModule.h"
-
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclCXX.h"
-#include "clang/AST/Mangle.h"
-
-using namespace clang;
-using namespace clang::CIRGen;
-
-namespace {
-
-class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
-public:
-  CIRGenMicrosoftCXXABI(CIRGenModule &cgm) : CIRGenCXXABI(cgm) {}
-
-  AddedStructorArgCounts
-  buildStructorSignature(GlobalDecl gd,
-                         llvm::SmallVectorImpl<CanQualType> &argTys) override {
-    return AddedStructorArgCounts{};
-  }
-
-  void addImplicitStructorParams(CIRGenFunction &cgf, QualType &resTy,
-                                 FunctionArgList &params) override {}
-
-  void emitInstanceFunctionProlog(SourceLocation loc,
-                                  CIRGenFunction &cgf) override {}
-
-  AddedStructorArgs getImplicitConstructorArgs(CIRGenFunction &cgf,
-                                               const CXXConstructorDecl *d,
-                                               CXXCtorType type,
-                                               bool forVirtualBase,
-                                               bool delegating) override {
-    return AddedStructorArgs{};
-  }
-
-  mlir::Value getCXXDestructorImplicitParam(CIRGenFunction &cgf,
-                                            const CXXDestructorDecl *dd,
-                                            CXXDtorType type,
-                                            bool forVirtualBase,
-                                            bool delegating) override {
-    return nullptr;
-  }
-
-  void emitCXXConstructors(const CXXConstructorDecl *d) override {
-    cgm.errorNYI(d->getSourceRange(), "emitCXXConstructors: MSVC ABI");
-  }
-
-  void emitCXXDestructors(const CXXDestructorDecl *d) override {
-    cgm.errorNYI(d->getSourceRange(), "emitCXXDestructors: MSVC ABI");
-  }
-
-  void emitCXXStructor(GlobalDecl gd) override {
-    cgm.errorNYI(gd.getDecl()->getSourceRange(), "emitCXXStructor: MSVC ABI");
-  }
-
-  void emitDestructorCall(CIRGenFunction &cgf, const CXXDestructorDecl *dd,
-                          CXXDtorType type, bool forVirtualBase,
-                          bool delegating, Address thisAddr,
-                          QualType thisTy) override {
-    cgf.cgm.errorNYI(dd->getSourceRange(), "emitDestructorCall: MSVC ABI");
-  }
-
-  mlir::Value emitVirtualDestructorCall(CIRGenFunction &cgf,
-                                        const CXXDestructorDecl *dtor,
-                                        CXXDtorType dtorType, Address thisAddr,
-                                        DeleteOrMemberCallExpr e) override {
-    cgf.cgm.errorNYI(dtor->getSourceRange(),
-                     "emitVirtualDestructorCall: MSVC ABI");
-    return nullptr;
-  }
-
-  void emitVirtualObjectDelete(CIRGenFunction &cgf, const CXXDeleteExpr *de,
-                               Address ptr, QualType elementType,
-                               const CXXDestructorDecl *dtor) override {
-    cgf.cgm.errorNYI(de->getSourceRange(), "emitVirtualObjectDelete: MSVC 
ABI");
-  }
-
-  const CXXRecordDecl *
-  getThisArgumentTypeForMethod(const CXXMethodDecl *md) override {
-    return md->getParent();
-  }
-
-  Address adjustThisArgumentForVirtualFunctionCall(CIRGenFunction &cgf,
-                                                   GlobalDecl gd,
-                                                   Address thisAddr,
-                                                   bool virtualCall) override {
-    return thisAddr;
-  }
-
-  bool isVirtualOffsetNeededForVTableField(CIRGenFunction &cgf,
-                                           CIRGenFunction::VPtr vptr) override 
{
-    return false;
-  }
-
-  cir::GlobalOp getAddrOfVTable(const CXXRecordDecl *rd,
-                                CharUnits vptrOffset) override {
-    cgm.errorNYI(rd->getSourceRange(), "getAddrOfVTable: MSVC ABI");
-    return nullptr;
-  }
-
-  mlir::Value getVTableAddressPoint(BaseSubobject base,
-                                    const CXXRecordDecl *vtableClass) override 
{
-    cgm.errorNYI(vtableClass->getSourceRange(),
-                 "getVTableAddressPoint: MSVC ABI");
-    return nullptr;
-  }
-
-  mlir::Value getVTableAddressPointInStructor(
-      CIRGenFunction &cgf, const CXXRecordDecl *vtableClass, BaseSubobject 
base,
-      const CXXRecordDecl *nearestVBase) override {
-    cgf.cgm.errorNYI(vtableClass->getSourceRange(),
-                     "getVTableAddressPointInStructor: MSVC ABI");
-    return nullptr;
-  }
-
-  CIRGenCallee getVirtualFunctionPointer(CIRGenFunction &cgf, GlobalDecl gd,
-                                         Address thisAddr, mlir::Type ty,
-                                         SourceLocation loc) override {
-    cgf.cgm.errorNYI(loc, "getVirtualFunctionPointer: MSVC ABI");
-    return CIRGenCallee();
-  }
-
-  void emitVTableDefinitions(CIRGenVTables &cgvt,
-                             const CXXRecordDecl *rd) override {
-    cgm.errorNYI(rd->getSourceRange(), "emitVTableDefinitions: MSVC ABI");
-  }
-
-  void emitVirtualInheritanceTables(const CXXRecordDecl *rd) override {
-    if (rd->getNumVBases())
-      cgm.errorNYI(rd->getSourceRange(),
-                   "emitVirtualInheritanceTables: MSVC VBTables");
-  }
-
-  void
-  initializeHiddenVirtualInheritanceMembers(CIRGenFunction &cgf,
-                                            const CXXRecordDecl *rd) override {
-    if (rd->getNumVBases())
-      cgf.cgm.errorNYI(rd->getSourceRange(),
-                       "initializeHiddenVirtualInheritanceMembers: vbptr 
stores");
-  }
-
-  mlir::Value
-  getVirtualBaseClassOffset(mlir::Location loc, CIRGenFunction &cgf,
-                            Address thisAddr, const CXXRecordDecl *classDecl,
-                            const CXXRecordDecl *baseClassDecl) override {
-    cgf.cgm.errorNYI(loc, "getVirtualBaseClassOffset: MSVC ABI");
-    return nullptr;
-  }
-
-  cir::MethodAttr buildVirtualMethodAttr(cir::MethodType methodTy,
-                                         const CXXMethodDecl *md) override {
-    cgm.errorNYI(md->getSourceRange(), "buildVirtualMethodAttr: MSVC ABI");
-    return cir::MethodAttr();
-  }
-
-  mlir::Value performThisAdjustment(CIRGenFunction &cgf, Address thisAddr,
-                                    const CXXRecordDecl *unadjustedClass,
-                                    const ThunkInfo &ti) override {
-    return thisAddr.emitRawPointer();
-  }
-
-  mlir::Value performReturnAdjustment(CIRGenFunction &cgf, Address ret,
-                                      const CXXRecordDecl *unadjustedClass,
-                                      const ReturnAdjustment &ra) override {
-    return ret.emitRawPointer();
-  }
-
-  bool canSpeculativelyEmitVTable(const CXXRecordDecl *rd) const override {
-    return false;
-  }
-
-  bool doStructorsInitializeVPtrs(const CXXRecordDecl *vtableClass) override {
-    return false;
-  }
-
-  bool exportThunk() override { return false; }
-
-  bool useThunkForDtorVariant(const CXXDestructorDecl *dtor,
-                              CXXDtorType dt) const override {
-    return false;
-  }
-
-  void setThunkLinkage(cir::FuncOp thunk, bool forVTable, GlobalDecl gd,
-                       bool returnAdjustment) override {
-    thunk.setLinkage(cir::GlobalLinkageKind::LinkOnceODRLinkage);
-  }
-
-  llvm::StringRef getPureVirtualCallName() override { return "_purecall"; }
-  llvm::StringRef getDeletedVirtualCallName() override { return "_purecall"; }
-
-  bool isZeroInitializable(const MemberPointerType *mpt) override {
-    return true;
-  }
-
-  bool requiresArrayCookie(const CXXNewExpr *e) override {
-    return false;
-  }
-
-  CharUnits getArrayCookieSizeImpl(QualType elementType) override {
-    return CharUnits::Zero();
-  }
-
-  Address initializeArrayCookie(CIRGenFunction &cgf, Address newPtr,
-                                mlir::Value numElements, const CXXNewExpr *e,
-                                QualType elementType) override {
-    cgf.cgm.errorNYI(e->getSourceRange(), "initializeArrayCookie: MSVC ABI");
-    return newPtr;
-  }
-
-  bool shouldTypeidBeNullChecked(QualType srcTy) override {
-    return false;
-  }
-
-  mlir::Value emitTypeid(CIRGenFunction &cgf, QualType srcTy, Address thisPtr,
-                         mlir::Type typeInfoPtrTy) override {
-    cgf.cgm.errorNYI(cgf.getLoc(srcTy->getAsCXXRecordDecl()->getLocation()),
-                     "emitTypeid: MSVC ABI");
-    return cgf.getBuilder().getNullPtr(
-        typeInfoPtrTy, cgf.getLoc(srcTy->getAsCXXRecordDecl()->getLocation()));
-  }
-
-  void emitBadTypeidCall(CIRGenFunction &cgf, mlir::Location loc) override {
-    cgf.cgm.errorNYI(loc, "emitBadTypeidCall: MSVC ABI");
-  }
-
-  void emitBadCastCall(CIRGenFunction &cgf, mlir::Location loc) override {
-    cgm.errorNYI(loc, "emitBadCastCall: MSVC ABI");
-  }
-
-  mlir::Value emitDynamicCast(CIRGenFunction &cgf, mlir::Location loc,
-                              QualType srcRecordTy, QualType destRecordTy,
-                              cir::PointerType destCIRTy, bool isRefCast,
-                              Address src) override {
-    cgf.cgm.errorNYI(loc, "emitDynamicCast: MSVC ABI");
-    return cgf.getBuilder().getNullPtr(destCIRTy, loc);
-  }
-
-  mlir::Attribute getAddrOfRTTIDescriptor(mlir::Location loc,
-                                         QualType ty) override {
-    cgm.errorNYI(loc, "getAddrOfRTTIDescriptor: MSVC ABI");
-    return nullptr;
-  }
-
-  CatchTypeInfo getCatchAllTypeInfo() override {
-    return CatchTypeInfo{nullptr, 0};
-  }
-
-  CatchTypeInfo
-  getAddrOfCXXCatchHandlerType(mlir::Location loc, QualType ty,
-                               QualType catchHandlerType) override {
-    cgm.errorNYI(loc, "getAddrOfCXXCatchHandlerType: MSVC ABI");
-    return CatchTypeInfo{nullptr, 0};
-  }
-
-  void emitRethrow(CIRGenFunction &cgf, bool isNoReturn) override {
-    cgm.errorNYI("emitRethrow: MSVC ABI");
-  }
-
-  void emitThrow(CIRGenFunction &cgf, const CXXThrowExpr *e) override {
-    cgf.cgm.errorNYI(e->getSourceRange(), "emitThrow: MSVC ABI");
-  }
-
-  void registerGlobalDtor(const VarDecl *vd, cir::FuncOp dtor,
-                          mlir::Value addr) override {}
-};
-
-} // namespace
-
-CIRGenCXXABI *clang::CIRGen::CreateCIRGenMicrosoftCXXABI(CIRGenModule &cgm) {
-  return new CIRGenMicrosoftCXXABI(cgm);
-}
+//===--- CIRGenMicrosoftCXXABI.cpp - Emit CIR Code for MS C++ ABI --------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This provides C++ code generation targeting the Microsoft C++ ABI.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CIRGenCXXABI.h"
+#include "CIRGenFunction.h"
+#include "CIRGenModule.h"
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Mangle.h"
+
+using namespace clang;
+using namespace clang::CIRGen;
+
+namespace {
+
+class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
+public:
+  CIRGenMicrosoftCXXABI(CIRGenModule &cgm) : CIRGenCXXABI(cgm) {}
+
+  AddedStructorArgCounts
+  buildStructorSignature(GlobalDecl gd,
+                         llvm::SmallVectorImpl<CanQualType> &argTys) override {
+    return AddedStructorArgCounts{};
+  }
+
+  void addImplicitStructorParams(CIRGenFunction &cgf, QualType &resTy,
+                                 FunctionArgList &params) override {}
+
+  void emitInstanceFunctionProlog(SourceLocation loc,
+                                  CIRGenFunction &cgf) override {}
+
+  AddedStructorArgs getImplicitConstructorArgs(CIRGenFunction &cgf,
+                                               const CXXConstructorDecl *d,
+                                               CXXCtorType type,
+                                               bool forVirtualBase,
+                                               bool delegating) override {
+    return AddedStructorArgs{};
+  }
+
+  mlir::Value getCXXDestructorImplicitParam(CIRGenFunction &cgf,
+                                            const CXXDestructorDecl *dd,
+                                            CXXDtorType type,
+                                            bool forVirtualBase,
+                                            bool delegating) override {
+    return nullptr;
+  }
+
+  void emitCXXConstructors(const CXXConstructorDecl *d) override {
+    cgm.errorNYI(d->getSourceRange(), "emitCXXConstructors: MSVC ABI");
+  }
+
+  void emitCXXDestructors(const CXXDestructorDecl *d) override {
+    cgm.errorNYI(d->getSourceRange(), "emitCXXDestructors: MSVC ABI");
+  }
+
+  void emitCXXStructor(GlobalDecl gd) override {
+    cgm.errorNYI(gd.getDecl()->getSourceRange(), "emitCXXStructor: MSVC ABI");
+  }
+
+  void emitDestructorCall(CIRGenFunction &cgf, const CXXDestructorDecl *dd,
+                          CXXDtorType type, bool forVirtualBase,
+                          bool delegating, Address thisAddr,
+                          QualType thisTy) override {
+    cgf.cgm.errorNYI(dd->getSourceRange(), "emitDestructorCall: MSVC ABI");
+  }
+
+  mlir::Value emitVirtualDestructorCall(CIRGenFunction &cgf,
+                                        const CXXDestructorDecl *dtor,
+                                        CXXDtorType dtorType, Address thisAddr,
+                                        DeleteOrMemberCallExpr e) override {
+    cgf.cgm.errorNYI(dtor->getSourceRange(),
+                     "emitVirtualDestructorCall: MSVC ABI");
+    return nullptr;
+  }
+
+  void emitVirtualObjectDelete(CIRGenFunction &cgf, const CXXDeleteExpr *de,
+                               Address ptr, QualType elementType,
+                               const CXXDestructorDecl *dtor) override {
+    cgf.cgm.errorNYI(de->getSourceRange(), "emitVirtualObjectDelete: MSVC 
ABI");
+  }
+
+  const CXXRecordDecl *
+  getThisArgumentTypeForMethod(const CXXMethodDecl *md) override {
+    return md->getParent();
+  }
+
+  Address adjustThisArgumentForVirtualFunctionCall(CIRGenFunction &cgf,
+                                                   GlobalDecl gd,
+                                                   Address thisAddr,
+                                                   bool virtualCall) override {
+    return thisAddr;
+  }
+
+  bool isVirtualOffsetNeededForVTableField(CIRGenFunction &cgf,
+                                           CIRGenFunction::VPtr vptr) override 
{
+    return false;
+  }
+
+  cir::GlobalOp getAddrOfVTable(const CXXRecordDecl *rd,
+                                CharUnits vptrOffset) override {
+    cgm.errorNYI(rd->getSourceRange(), "getAddrOfVTable: MSVC ABI");
+    return nullptr;
+  }
+
+  mlir::Value getVTableAddressPoint(BaseSubobject base,
+                                    const CXXRecordDecl *vtableClass) override 
{
+    cgm.errorNYI(vtableClass->getSourceRange(),
+                 "getVTableAddressPoint: MSVC ABI");
+    return nullptr;
+  }
+
+  mlir::Value getVTableAddressPointInStructor(
+      CIRGenFunction &cgf, const CXXRecordDecl *vtableClass, BaseSubobject 
base,
+      const CXXRecordDecl *nearestVBase) override {
+    cgf.cgm.errorNYI(vtableClass->getSourceRange(),
+                     "getVTableAddressPointInStructor: MSVC ABI");
+    return nullptr;
+  }
+
+  CIRGenCallee getVirtualFunctionPointer(CIRGenFunction &cgf, GlobalDecl gd,
+                                         Address thisAddr, mlir::Type ty,
+                                         SourceLocation loc) override {
+    cgf.cgm.errorNYI(loc, "getVirtualFunctionPointer: MSVC ABI");
+    return CIRGenCallee();
+  }
+
+  void emitVTableDefinitions(CIRGenVTables &cgvt,
+                             const CXXRecordDecl *rd) override {
+    cgm.errorNYI(rd->getSourceRange(), "emitVTableDefinitions: MSVC ABI");
+  }
+
+  void emitVirtualInheritanceTables(const CXXRecordDecl *rd) override {
+    if (rd->getNumVBases())
+      cgm.errorNYI(rd->getSourceRange(),
+                   "emitVirtualInheritanceTables: MSVC VBTables");
+  }
+
+  void
+  initializeHiddenVirtualInheritanceMembers(CIRGenFunction &cgf,
+                                            const CXXRecordDecl *rd) override {
+    if (rd->getNumVBases())
+      cgf.cgm.errorNYI(
+          rd->getSourceRange(),
+          "initializeHiddenVirtualInheritanceMembers: vbptr stores");
+  }
+
+  mlir::Value
+  getVirtualBaseClassOffset(mlir::Location loc, CIRGenFunction &cgf,
+                            Address thisAddr, const CXXRecordDecl *classDecl,
+                            const CXXRecordDecl *baseClassDecl) override {
+    cgf.cgm.errorNYI(loc, "getVirtualBaseClassOffset: MSVC ABI");
+    return nullptr;
+  }
+
+  cir::MethodAttr buildVirtualMethodAttr(cir::MethodType methodTy,
+                                         const CXXMethodDecl *md) override {
+    cgm.errorNYI(md->getSourceRange(), "buildVirtualMethodAttr: MSVC ABI");
+    return cir::MethodAttr();
+  }
+
+  mlir::Value performThisAdjustment(CIRGenFunction &cgf, Address thisAddr,
+                                    const CXXRecordDecl *unadjustedClass,
+                                    const ThunkInfo &ti) override {
+    return thisAddr.emitRawPointer();
+  }
+
+  mlir::Value performReturnAdjustment(CIRGenFunction &cgf, Address ret,
+                                      const CXXRecordDecl *unadjustedClass,
+                                      const ReturnAdjustment &ra) override {
+    return ret.emitRawPointer();
+  }
+
+  bool canSpeculativelyEmitVTable(const CXXRecordDecl *rd) const override {
+    return false;
+  }
+
+  bool doStructorsInitializeVPtrs(const CXXRecordDecl *vtableClass) override {
+    return false;
+  }
+
+  bool exportThunk() override { return false; }
+
+  bool useThunkForDtorVariant(const CXXDestructorDecl *dtor,
+                              CXXDtorType dt) const override {
+    return false;
+  }
+
+  void setThunkLinkage(cir::FuncOp thunk, bool forVTable, GlobalDecl gd,
+                       bool returnAdjustment) override {
+    thunk.setLinkage(cir::GlobalLinkageKind::LinkOnceODRLinkage);
+  }
+
+  llvm::StringRef getPureVirtualCallName() override { return "_purecall"; }
+  llvm::StringRef getDeletedVirtualCallName() override { return "_purecall"; }
+
+  bool isZeroInitializable(const MemberPointerType *mpt) override {
+    return true;
+  }
+
+  bool requiresArrayCookie(const CXXNewExpr *e) override { return false; }
+
+  CharUnits getArrayCookieSizeImpl(QualType elementType) override {
+    return CharUnits::Zero();
+  }
+
+  Address initializeArrayCookie(CIRGenFunction &cgf, Address newPtr,
+                                mlir::Value numElements, const CXXNewExpr *e,
+                                QualType elementType) override {
+    cgf.cgm.errorNYI(e->getSourceRange(), "initializeArrayCookie: MSVC ABI");
+    return newPtr;
+  }
+
+  bool shouldTypeidBeNullChecked(QualType srcTy) override { return false; }
+
+  mlir::Value emitTypeid(CIRGenFunction &cgf, QualType srcTy, Address thisPtr,
+                         mlir::Type typeInfoPtrTy) override {
+    cgf.cgm.errorNYI(cgf.getLoc(srcTy->getAsCXXRecordDecl()->getLocation()),
+                     "emitTypeid: MSVC ABI");
+    return cgf.getBuilder().getNullPtr(
+        typeInfoPtrTy, cgf.getLoc(srcTy->getAsCXXRecordDecl()->getLocation()));
+  }
+
+  void emitBadTypeidCall(CIRGenFunction &cgf, mlir::Location loc) override {
+    cgf.cgm.errorNYI(loc, "emitBadTypeidCall: MSVC ABI");
+  }
+
+  void emitBadCastCall(CIRGenFunction &cgf, mlir::Location loc) override {
+    cgm.errorNYI(loc, "emitBadCastCall: MSVC ABI");
+  }
+
+  mlir::Value emitDynamicCast(CIRGenFunction &cgf, mlir::Location loc,
+                              QualType srcRecordTy, QualType destRecordTy,
+                              cir::PointerType destCIRTy, bool isRefCast,
+                              Address src) override {
+    cgf.cgm.errorNYI(loc, "emitDynamicCast: MSVC ABI");
+    return cgf.getBuilder().getNullPtr(destCIRTy, loc);
+  }
+
+  mlir::Attribute getAddrOfRTTIDescriptor(mlir::Location loc,
+                                          QualType ty) override {
+    cgm.errorNYI(loc, "getAddrOfRTTIDescriptor: MSVC ABI");
+    return nullptr;
+  }
+
+  CatchTypeInfo getCatchAllTypeInfo() override {
+    return CatchTypeInfo{nullptr, 0};
+  }
+
+  CatchTypeInfo
+  getAddrOfCXXCatchHandlerType(mlir::Location loc, QualType ty,
+                               QualType catchHandlerType) override {
+    cgm.errorNYI(loc, "getAddrOfCXXCatchHandlerType: MSVC ABI");
+    return CatchTypeInfo{nullptr, 0};
+  }
+
+  void emitRethrow(CIRGenFunction &cgf, bool isNoReturn) override {
+    cgm.errorNYI("emitRethrow: MSVC ABI");
+  }
+
+  void emitThrow(CIRGenFunction &cgf, const CXXThrowExpr *e) override {
+    cgf.cgm.errorNYI(e->getSourceRange(), "emitThrow: MSVC ABI");
+  }
+
+  void registerGlobalDtor(const VarDecl *vd, cir::FuncOp dtor,
+                          mlir::Value addr) override {}
+};
+
+} // namespace
+
+CIRGenCXXABI *clang::CIRGen::CreateCIRGenMicrosoftCXXABI(CIRGenModule &cgm) {
+  return new CIRGenMicrosoftCXXABI(cgm);
+}

>From 7402e033e8cc3332b6b646e1ec7242681edadfad Mon Sep 17 00:00:00 2001
From: R-Goc <[email protected]>
Date: Thu, 3 Sep 2026 23:19:22 +0200
Subject: [PATCH 3/5] fix line endings

---
 .../lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp | 564 +++++++++---------
 1 file changed, 282 insertions(+), 282 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp 
b/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp
index 9e5faa5b5e54d..0b7c4d3164d97 100644
--- a/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp
@@ -1,282 +1,282 @@
-//===--- CIRGenMicrosoftCXXABI.cpp - Emit CIR Code for MS C++ ABI --------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-//
-// This provides C++ code generation targeting the Microsoft C++ ABI.
-//
-//===----------------------------------------------------------------------===//
-
-#include "CIRGenCXXABI.h"
-#include "CIRGenFunction.h"
-#include "CIRGenModule.h"
-
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclCXX.h"
-#include "clang/AST/Mangle.h"
-
-using namespace clang;
-using namespace clang::CIRGen;
-
-namespace {
-
-class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
-public:
-  CIRGenMicrosoftCXXABI(CIRGenModule &cgm) : CIRGenCXXABI(cgm) {}
-
-  AddedStructorArgCounts
-  buildStructorSignature(GlobalDecl gd,
-                         llvm::SmallVectorImpl<CanQualType> &argTys) override {
-    return AddedStructorArgCounts{};
-  }
-
-  void addImplicitStructorParams(CIRGenFunction &cgf, QualType &resTy,
-                                 FunctionArgList &params) override {}
-
-  void emitInstanceFunctionProlog(SourceLocation loc,
-                                  CIRGenFunction &cgf) override {}
-
-  AddedStructorArgs getImplicitConstructorArgs(CIRGenFunction &cgf,
-                                               const CXXConstructorDecl *d,
-                                               CXXCtorType type,
-                                               bool forVirtualBase,
-                                               bool delegating) override {
-    return AddedStructorArgs{};
-  }
-
-  mlir::Value getCXXDestructorImplicitParam(CIRGenFunction &cgf,
-                                            const CXXDestructorDecl *dd,
-                                            CXXDtorType type,
-                                            bool forVirtualBase,
-                                            bool delegating) override {
-    return nullptr;
-  }
-
-  void emitCXXConstructors(const CXXConstructorDecl *d) override {
-    cgm.errorNYI(d->getSourceRange(), "emitCXXConstructors: MSVC ABI");
-  }
-
-  void emitCXXDestructors(const CXXDestructorDecl *d) override {
-    cgm.errorNYI(d->getSourceRange(), "emitCXXDestructors: MSVC ABI");
-  }
-
-  void emitCXXStructor(GlobalDecl gd) override {
-    cgm.errorNYI(gd.getDecl()->getSourceRange(), "emitCXXStructor: MSVC ABI");
-  }
-
-  void emitDestructorCall(CIRGenFunction &cgf, const CXXDestructorDecl *dd,
-                          CXXDtorType type, bool forVirtualBase,
-                          bool delegating, Address thisAddr,
-                          QualType thisTy) override {
-    cgf.cgm.errorNYI(dd->getSourceRange(), "emitDestructorCall: MSVC ABI");
-  }
-
-  mlir::Value emitVirtualDestructorCall(CIRGenFunction &cgf,
-                                        const CXXDestructorDecl *dtor,
-                                        CXXDtorType dtorType, Address thisAddr,
-                                        DeleteOrMemberCallExpr e) override {
-    cgf.cgm.errorNYI(dtor->getSourceRange(),
-                     "emitVirtualDestructorCall: MSVC ABI");
-    return nullptr;
-  }
-
-  void emitVirtualObjectDelete(CIRGenFunction &cgf, const CXXDeleteExpr *de,
-                               Address ptr, QualType elementType,
-                               const CXXDestructorDecl *dtor) override {
-    cgf.cgm.errorNYI(de->getSourceRange(), "emitVirtualObjectDelete: MSVC 
ABI");
-  }
-
-  const CXXRecordDecl *
-  getThisArgumentTypeForMethod(const CXXMethodDecl *md) override {
-    return md->getParent();
-  }
-
-  Address adjustThisArgumentForVirtualFunctionCall(CIRGenFunction &cgf,
-                                                   GlobalDecl gd,
-                                                   Address thisAddr,
-                                                   bool virtualCall) override {
-    return thisAddr;
-  }
-
-  bool isVirtualOffsetNeededForVTableField(CIRGenFunction &cgf,
-                                           CIRGenFunction::VPtr vptr) override 
{
-    return false;
-  }
-
-  cir::GlobalOp getAddrOfVTable(const CXXRecordDecl *rd,
-                                CharUnits vptrOffset) override {
-    cgm.errorNYI(rd->getSourceRange(), "getAddrOfVTable: MSVC ABI");
-    return nullptr;
-  }
-
-  mlir::Value getVTableAddressPoint(BaseSubobject base,
-                                    const CXXRecordDecl *vtableClass) override 
{
-    cgm.errorNYI(vtableClass->getSourceRange(),
-                 "getVTableAddressPoint: MSVC ABI");
-    return nullptr;
-  }
-
-  mlir::Value getVTableAddressPointInStructor(
-      CIRGenFunction &cgf, const CXXRecordDecl *vtableClass, BaseSubobject 
base,
-      const CXXRecordDecl *nearestVBase) override {
-    cgf.cgm.errorNYI(vtableClass->getSourceRange(),
-                     "getVTableAddressPointInStructor: MSVC ABI");
-    return nullptr;
-  }
-
-  CIRGenCallee getVirtualFunctionPointer(CIRGenFunction &cgf, GlobalDecl gd,
-                                         Address thisAddr, mlir::Type ty,
-                                         SourceLocation loc) override {
-    cgf.cgm.errorNYI(loc, "getVirtualFunctionPointer: MSVC ABI");
-    return CIRGenCallee();
-  }
-
-  void emitVTableDefinitions(CIRGenVTables &cgvt,
-                             const CXXRecordDecl *rd) override {
-    cgm.errorNYI(rd->getSourceRange(), "emitVTableDefinitions: MSVC ABI");
-  }
-
-  void emitVirtualInheritanceTables(const CXXRecordDecl *rd) override {
-    if (rd->getNumVBases())
-      cgm.errorNYI(rd->getSourceRange(),
-                   "emitVirtualInheritanceTables: MSVC VBTables");
-  }
-
-  void
-  initializeHiddenVirtualInheritanceMembers(CIRGenFunction &cgf,
-                                            const CXXRecordDecl *rd) override {
-    if (rd->getNumVBases())
-      cgf.cgm.errorNYI(
-          rd->getSourceRange(),
-          "initializeHiddenVirtualInheritanceMembers: vbptr stores");
-  }
-
-  mlir::Value
-  getVirtualBaseClassOffset(mlir::Location loc, CIRGenFunction &cgf,
-                            Address thisAddr, const CXXRecordDecl *classDecl,
-                            const CXXRecordDecl *baseClassDecl) override {
-    cgf.cgm.errorNYI(loc, "getVirtualBaseClassOffset: MSVC ABI");
-    return nullptr;
-  }
-
-  cir::MethodAttr buildVirtualMethodAttr(cir::MethodType methodTy,
-                                         const CXXMethodDecl *md) override {
-    cgm.errorNYI(md->getSourceRange(), "buildVirtualMethodAttr: MSVC ABI");
-    return cir::MethodAttr();
-  }
-
-  mlir::Value performThisAdjustment(CIRGenFunction &cgf, Address thisAddr,
-                                    const CXXRecordDecl *unadjustedClass,
-                                    const ThunkInfo &ti) override {
-    return thisAddr.emitRawPointer();
-  }
-
-  mlir::Value performReturnAdjustment(CIRGenFunction &cgf, Address ret,
-                                      const CXXRecordDecl *unadjustedClass,
-                                      const ReturnAdjustment &ra) override {
-    return ret.emitRawPointer();
-  }
-
-  bool canSpeculativelyEmitVTable(const CXXRecordDecl *rd) const override {
-    return false;
-  }
-
-  bool doStructorsInitializeVPtrs(const CXXRecordDecl *vtableClass) override {
-    return false;
-  }
-
-  bool exportThunk() override { return false; }
-
-  bool useThunkForDtorVariant(const CXXDestructorDecl *dtor,
-                              CXXDtorType dt) const override {
-    return false;
-  }
-
-  void setThunkLinkage(cir::FuncOp thunk, bool forVTable, GlobalDecl gd,
-                       bool returnAdjustment) override {
-    thunk.setLinkage(cir::GlobalLinkageKind::LinkOnceODRLinkage);
-  }
-
-  llvm::StringRef getPureVirtualCallName() override { return "_purecall"; }
-  llvm::StringRef getDeletedVirtualCallName() override { return "_purecall"; }
-
-  bool isZeroInitializable(const MemberPointerType *mpt) override {
-    return true;
-  }
-
-  bool requiresArrayCookie(const CXXNewExpr *e) override { return false; }
-
-  CharUnits getArrayCookieSizeImpl(QualType elementType) override {
-    return CharUnits::Zero();
-  }
-
-  Address initializeArrayCookie(CIRGenFunction &cgf, Address newPtr,
-                                mlir::Value numElements, const CXXNewExpr *e,
-                                QualType elementType) override {
-    cgf.cgm.errorNYI(e->getSourceRange(), "initializeArrayCookie: MSVC ABI");
-    return newPtr;
-  }
-
-  bool shouldTypeidBeNullChecked(QualType srcTy) override { return false; }
-
-  mlir::Value emitTypeid(CIRGenFunction &cgf, QualType srcTy, Address thisPtr,
-                         mlir::Type typeInfoPtrTy) override {
-    cgf.cgm.errorNYI(cgf.getLoc(srcTy->getAsCXXRecordDecl()->getLocation()),
-                     "emitTypeid: MSVC ABI");
-    return cgf.getBuilder().getNullPtr(
-        typeInfoPtrTy, cgf.getLoc(srcTy->getAsCXXRecordDecl()->getLocation()));
-  }
-
-  void emitBadTypeidCall(CIRGenFunction &cgf, mlir::Location loc) override {
-    cgf.cgm.errorNYI(loc, "emitBadTypeidCall: MSVC ABI");
-  }
-
-  void emitBadCastCall(CIRGenFunction &cgf, mlir::Location loc) override {
-    cgm.errorNYI(loc, "emitBadCastCall: MSVC ABI");
-  }
-
-  mlir::Value emitDynamicCast(CIRGenFunction &cgf, mlir::Location loc,
-                              QualType srcRecordTy, QualType destRecordTy,
-                              cir::PointerType destCIRTy, bool isRefCast,
-                              Address src) override {
-    cgf.cgm.errorNYI(loc, "emitDynamicCast: MSVC ABI");
-    return cgf.getBuilder().getNullPtr(destCIRTy, loc);
-  }
-
-  mlir::Attribute getAddrOfRTTIDescriptor(mlir::Location loc,
-                                          QualType ty) override {
-    cgm.errorNYI(loc, "getAddrOfRTTIDescriptor: MSVC ABI");
-    return nullptr;
-  }
-
-  CatchTypeInfo getCatchAllTypeInfo() override {
-    return CatchTypeInfo{nullptr, 0};
-  }
-
-  CatchTypeInfo
-  getAddrOfCXXCatchHandlerType(mlir::Location loc, QualType ty,
-                               QualType catchHandlerType) override {
-    cgm.errorNYI(loc, "getAddrOfCXXCatchHandlerType: MSVC ABI");
-    return CatchTypeInfo{nullptr, 0};
-  }
-
-  void emitRethrow(CIRGenFunction &cgf, bool isNoReturn) override {
-    cgm.errorNYI("emitRethrow: MSVC ABI");
-  }
-
-  void emitThrow(CIRGenFunction &cgf, const CXXThrowExpr *e) override {
-    cgf.cgm.errorNYI(e->getSourceRange(), "emitThrow: MSVC ABI");
-  }
-
-  void registerGlobalDtor(const VarDecl *vd, cir::FuncOp dtor,
-                          mlir::Value addr) override {}
-};
-
-} // namespace
-
-CIRGenCXXABI *clang::CIRGen::CreateCIRGenMicrosoftCXXABI(CIRGenModule &cgm) {
-  return new CIRGenMicrosoftCXXABI(cgm);
-}
+//===--- CIRGenMicrosoftCXXABI.cpp - Emit CIR Code for MS C++ ABI --------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This provides C++ code generation targeting the Microsoft C++ ABI.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CIRGenCXXABI.h"
+#include "CIRGenFunction.h"
+#include "CIRGenModule.h"
+
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Mangle.h"
+
+using namespace clang;
+using namespace clang::CIRGen;
+
+namespace {
+
+class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
+public:
+  CIRGenMicrosoftCXXABI(CIRGenModule &cgm) : CIRGenCXXABI(cgm) {}
+
+  AddedStructorArgCounts
+  buildStructorSignature(GlobalDecl gd,
+                         llvm::SmallVectorImpl<CanQualType> &argTys) override {
+    return AddedStructorArgCounts{};
+  }
+
+  void addImplicitStructorParams(CIRGenFunction &cgf, QualType &resTy,
+                                 FunctionArgList &params) override {}
+
+  void emitInstanceFunctionProlog(SourceLocation loc,
+                                  CIRGenFunction &cgf) override {}
+
+  AddedStructorArgs getImplicitConstructorArgs(CIRGenFunction &cgf,
+                                               const CXXConstructorDecl *d,
+                                               CXXCtorType type,
+                                               bool forVirtualBase,
+                                               bool delegating) override {
+    return AddedStructorArgs{};
+  }
+
+  mlir::Value getCXXDestructorImplicitParam(CIRGenFunction &cgf,
+                                            const CXXDestructorDecl *dd,
+                                            CXXDtorType type,
+                                            bool forVirtualBase,
+                                            bool delegating) override {
+    return nullptr;
+  }
+
+  void emitCXXConstructors(const CXXConstructorDecl *d) override {
+    cgm.errorNYI(d->getSourceRange(), "emitCXXConstructors: MSVC ABI");
+  }
+
+  void emitCXXDestructors(const CXXDestructorDecl *d) override {
+    cgm.errorNYI(d->getSourceRange(), "emitCXXDestructors: MSVC ABI");
+  }
+
+  void emitCXXStructor(GlobalDecl gd) override {
+    cgm.errorNYI(gd.getDecl()->getSourceRange(), "emitCXXStructor: MSVC ABI");
+  }
+
+  void emitDestructorCall(CIRGenFunction &cgf, const CXXDestructorDecl *dd,
+                          CXXDtorType type, bool forVirtualBase,
+                          bool delegating, Address thisAddr,
+                          QualType thisTy) override {
+    cgf.cgm.errorNYI(dd->getSourceRange(), "emitDestructorCall: MSVC ABI");
+  }
+
+  mlir::Value emitVirtualDestructorCall(CIRGenFunction &cgf,
+                                        const CXXDestructorDecl *dtor,
+                                        CXXDtorType dtorType, Address thisAddr,
+                                        DeleteOrMemberCallExpr e) override {
+    cgf.cgm.errorNYI(dtor->getSourceRange(),
+                     "emitVirtualDestructorCall: MSVC ABI");
+    return nullptr;
+  }
+
+  void emitVirtualObjectDelete(CIRGenFunction &cgf, const CXXDeleteExpr *de,
+                               Address ptr, QualType elementType,
+                               const CXXDestructorDecl *dtor) override {
+    cgf.cgm.errorNYI(de->getSourceRange(), "emitVirtualObjectDelete: MSVC 
ABI");
+  }
+
+  const CXXRecordDecl *
+  getThisArgumentTypeForMethod(const CXXMethodDecl *md) override {
+    return md->getParent();
+  }
+
+  Address adjustThisArgumentForVirtualFunctionCall(CIRGenFunction &cgf,
+                                                   GlobalDecl gd,
+                                                   Address thisAddr,
+                                                   bool virtualCall) override {
+    return thisAddr;
+  }
+
+  bool isVirtualOffsetNeededForVTableField(CIRGenFunction &cgf,
+                                           CIRGenFunction::VPtr vptr) override 
{
+    return false;
+  }
+
+  cir::GlobalOp getAddrOfVTable(const CXXRecordDecl *rd,
+                                CharUnits vptrOffset) override {
+    cgm.errorNYI(rd->getSourceRange(), "getAddrOfVTable: MSVC ABI");
+    return nullptr;
+  }
+
+  mlir::Value getVTableAddressPoint(BaseSubobject base,
+                                    const CXXRecordDecl *vtableClass) override 
{
+    cgm.errorNYI(vtableClass->getSourceRange(),
+                 "getVTableAddressPoint: MSVC ABI");
+    return nullptr;
+  }
+
+  mlir::Value getVTableAddressPointInStructor(
+      CIRGenFunction &cgf, const CXXRecordDecl *vtableClass, BaseSubobject 
base,
+      const CXXRecordDecl *nearestVBase) override {
+    cgf.cgm.errorNYI(vtableClass->getSourceRange(),
+                     "getVTableAddressPointInStructor: MSVC ABI");
+    return nullptr;
+  }
+
+  CIRGenCallee getVirtualFunctionPointer(CIRGenFunction &cgf, GlobalDecl gd,
+                                         Address thisAddr, mlir::Type ty,
+                                         SourceLocation loc) override {
+    cgf.cgm.errorNYI(loc, "getVirtualFunctionPointer: MSVC ABI");
+    return CIRGenCallee();
+  }
+
+  void emitVTableDefinitions(CIRGenVTables &cgvt,
+                             const CXXRecordDecl *rd) override {
+    cgm.errorNYI(rd->getSourceRange(), "emitVTableDefinitions: MSVC ABI");
+  }
+
+  void emitVirtualInheritanceTables(const CXXRecordDecl *rd) override {
+    if (rd->getNumVBases())
+      cgm.errorNYI(rd->getSourceRange(),
+                   "emitVirtualInheritanceTables: MSVC VBTables");
+  }
+
+  void
+  initializeHiddenVirtualInheritanceMembers(CIRGenFunction &cgf,
+                                            const CXXRecordDecl *rd) override {
+    if (rd->getNumVBases())
+      cgf.cgm.errorNYI(
+          rd->getSourceRange(),
+          "initializeHiddenVirtualInheritanceMembers: vbptr stores");
+  }
+
+  mlir::Value
+  getVirtualBaseClassOffset(mlir::Location loc, CIRGenFunction &cgf,
+                            Address thisAddr, const CXXRecordDecl *classDecl,
+                            const CXXRecordDecl *baseClassDecl) override {
+    cgf.cgm.errorNYI(loc, "getVirtualBaseClassOffset: MSVC ABI");
+    return nullptr;
+  }
+
+  cir::MethodAttr buildVirtualMethodAttr(cir::MethodType methodTy,
+                                         const CXXMethodDecl *md) override {
+    cgm.errorNYI(md->getSourceRange(), "buildVirtualMethodAttr: MSVC ABI");
+    return cir::MethodAttr();
+  }
+
+  mlir::Value performThisAdjustment(CIRGenFunction &cgf, Address thisAddr,
+                                    const CXXRecordDecl *unadjustedClass,
+                                    const ThunkInfo &ti) override {
+    return thisAddr.emitRawPointer();
+  }
+
+  mlir::Value performReturnAdjustment(CIRGenFunction &cgf, Address ret,
+                                      const CXXRecordDecl *unadjustedClass,
+                                      const ReturnAdjustment &ra) override {
+    return ret.emitRawPointer();
+  }
+
+  bool canSpeculativelyEmitVTable(const CXXRecordDecl *rd) const override {
+    return false;
+  }
+
+  bool doStructorsInitializeVPtrs(const CXXRecordDecl *vtableClass) override {
+    return false;
+  }
+
+  bool exportThunk() override { return false; }
+
+  bool useThunkForDtorVariant(const CXXDestructorDecl *dtor,
+                              CXXDtorType dt) const override {
+    return false;
+  }
+
+  void setThunkLinkage(cir::FuncOp thunk, bool forVTable, GlobalDecl gd,
+                       bool returnAdjustment) override {
+    thunk.setLinkage(cir::GlobalLinkageKind::LinkOnceODRLinkage);
+  }
+
+  llvm::StringRef getPureVirtualCallName() override { return "_purecall"; }
+  llvm::StringRef getDeletedVirtualCallName() override { return "_purecall"; }
+
+  bool isZeroInitializable(const MemberPointerType *mpt) override {
+    return true;
+  }
+
+  bool requiresArrayCookie(const CXXNewExpr *e) override { return false; }
+
+  CharUnits getArrayCookieSizeImpl(QualType elementType) override {
+    return CharUnits::Zero();
+  }
+
+  Address initializeArrayCookie(CIRGenFunction &cgf, Address newPtr,
+                                mlir::Value numElements, const CXXNewExpr *e,
+                                QualType elementType) override {
+    cgf.cgm.errorNYI(e->getSourceRange(), "initializeArrayCookie: MSVC ABI");
+    return newPtr;
+  }
+
+  bool shouldTypeidBeNullChecked(QualType srcTy) override { return false; }
+
+  mlir::Value emitTypeid(CIRGenFunction &cgf, QualType srcTy, Address thisPtr,
+                         mlir::Type typeInfoPtrTy) override {
+    cgf.cgm.errorNYI(cgf.getLoc(srcTy->getAsCXXRecordDecl()->getLocation()),
+                     "emitTypeid: MSVC ABI");
+    return cgf.getBuilder().getNullPtr(
+        typeInfoPtrTy, cgf.getLoc(srcTy->getAsCXXRecordDecl()->getLocation()));
+  }
+
+  void emitBadTypeidCall(CIRGenFunction &cgf, mlir::Location loc) override {
+    cgf.cgm.errorNYI(loc, "emitBadTypeidCall: MSVC ABI");
+  }
+
+  void emitBadCastCall(CIRGenFunction &cgf, mlir::Location loc) override {
+    cgm.errorNYI(loc, "emitBadCastCall: MSVC ABI");
+  }
+
+  mlir::Value emitDynamicCast(CIRGenFunction &cgf, mlir::Location loc,
+                              QualType srcRecordTy, QualType destRecordTy,
+                              cir::PointerType destCIRTy, bool isRefCast,
+                              Address src) override {
+    cgf.cgm.errorNYI(loc, "emitDynamicCast: MSVC ABI");
+    return cgf.getBuilder().getNullPtr(destCIRTy, loc);
+  }
+
+  mlir::Attribute getAddrOfRTTIDescriptor(mlir::Location loc,
+                                          QualType ty) override {
+    cgm.errorNYI(loc, "getAddrOfRTTIDescriptor: MSVC ABI");
+    return nullptr;
+  }
+
+  CatchTypeInfo getCatchAllTypeInfo() override {
+    return CatchTypeInfo{nullptr, 0};
+  }
+
+  CatchTypeInfo
+  getAddrOfCXXCatchHandlerType(mlir::Location loc, QualType ty,
+                               QualType catchHandlerType) override {
+    cgm.errorNYI(loc, "getAddrOfCXXCatchHandlerType: MSVC ABI");
+    return CatchTypeInfo{nullptr, 0};
+  }
+
+  void emitRethrow(CIRGenFunction &cgf, bool isNoReturn) override {
+    cgm.errorNYI("emitRethrow: MSVC ABI");
+  }
+
+  void emitThrow(CIRGenFunction &cgf, const CXXThrowExpr *e) override {
+    cgf.cgm.errorNYI(e->getSourceRange(), "emitThrow: MSVC ABI");
+  }
+
+  void registerGlobalDtor(const VarDecl *vd, cir::FuncOp dtor,
+                          mlir::Value addr) override {}
+};
+
+} // namespace
+
+CIRGenCXXABI *clang::CIRGen::CreateCIRGenMicrosoftCXXABI(CIRGenModule &cgm) {
+  return new CIRGenMicrosoftCXXABI(cgm);
+}

>From d39cc96194e3d6a3ac32a496d31f58a4021b02db Mon Sep 17 00:00:00 2001
From: R-Goc <[email protected]>
Date: Fri, 4 Sep 2026 01:02:10 +0200
Subject: [PATCH 4/5] fix missing method

---
 clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp 
b/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp
index 0b7c4d3164d97..9e3fc9a8f55a6 100644
--- a/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp
@@ -89,6 +89,18 @@ class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
     cgf.cgm.errorNYI(de->getSourceRange(), "emitVirtualObjectDelete: MSVC 
ABI");
   }
 
+  size_t getSrcArgforCopyCtor(const CXXConstructorDecl *cd,
+                              FunctionArgList &args) const override {
+    assert(args.size() >= 2 &&
+           "expected the arglist to have at least two args!");
+    // The 'most_derived' parameter goes second if the ctor is variadic and
+    // has v-bases.
+    if (cd->getParent()->getNumVBases() > 0 &&
+        cd->getType()->castAs<FunctionProtoType>()->isVariadic())
+      return 2;
+    return 1;
+  }
+
   const CXXRecordDecl *
   getThisArgumentTypeForMethod(const CXXMethodDecl *md) override {
     return md->getParent();

>From 72d4077bf650dbc489fc32a67edbd007052e1548 Mon Sep 17 00:00:00 2001
From: R-Goc <[email protected]>
Date: Tue, 15 Sep 2026 16:08:01 +0200
Subject: [PATCH 5/5] NYI everything

---
 .../lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp | 63 ++++++++++++++-----
 1 file changed, 47 insertions(+), 16 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp 
b/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp
index 9e3fc9a8f55a6..c8a29bfb550f2 100644
--- a/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenMicrosoftCXXABI.cpp
@@ -29,21 +29,30 @@ class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
 
   AddedStructorArgCounts
   buildStructorSignature(GlobalDecl gd,
-                         llvm::SmallVectorImpl<CanQualType> &argTys) override {
+                         SmallVectorImpl<CanQualType> &argTys) override {
+    cgm.errorNYI(gd.getDecl()->getSourceRange(),
+                 "buildStructorSignature: MSVC ABI");
     return AddedStructorArgCounts{};
   }
 
   void addImplicitStructorParams(CIRGenFunction &cgf, QualType &resTy,
-                                 FunctionArgList &params) override {}
+                                 FunctionArgList &params) override {
+    cgf.cgm.errorNYI(cgf.curGD.getDecl()->getSourceRange(),
+                     "addImplicitStructorParams: MSVC ABI");
+  }
 
   void emitInstanceFunctionProlog(SourceLocation loc,
-                                  CIRGenFunction &cgf) override {}
+                                  CIRGenFunction &cgf) override {
+    cgf.cgm.errorNYI(loc, "emitInstanceFunctionProlog: MSVC ABI");
+  }
 
   AddedStructorArgs getImplicitConstructorArgs(CIRGenFunction &cgf,
                                                const CXXConstructorDecl *d,
                                                CXXCtorType type,
                                                bool forVirtualBase,
                                                bool delegating) override {
+    cgf.cgm.errorNYI(d->getSourceRange(),
+                     "getImplicitConstructorArgs: MSVC ABI");
     return AddedStructorArgs{};
   }
 
@@ -52,6 +61,8 @@ class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
                                             CXXDtorType type,
                                             bool forVirtualBase,
                                             bool delegating) override {
+    cgf.cgm.errorNYI(dd->getSourceRange(),
+                     "getCXXDestructorImplicitParam: MSVC ABI");
     return nullptr;
   }
 
@@ -91,6 +102,7 @@ class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
 
   size_t getSrcArgforCopyCtor(const CXXConstructorDecl *cd,
                               FunctionArgList &args) const override {
+    cgm.errorNYI(cd->getSourceRange(), "getSrcArgforCopyCtor: MSVC ABI");
     assert(args.size() >= 2 &&
            "expected the arglist to have at least two args!");
     // The 'most_derived' parameter goes second if the ctor is variadic and
@@ -103,6 +115,8 @@ class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
 
   const CXXRecordDecl *
   getThisArgumentTypeForMethod(const CXXMethodDecl *md) override {
+    cgm.errorNYI(md->getSourceRange(),
+                 "getThisArgumentTypeForMethod: MSVC ABI");
     return md->getParent();
   }
 
@@ -110,11 +124,14 @@ class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
                                                    GlobalDecl gd,
                                                    Address thisAddr,
                                                    bool virtualCall) override {
+    cgf.cgm.errorNYI(gd.getDecl()->getSourceRange(),
+                     "adjustThisArgumentForVirtualFunctionCall: MSVC ABI");
     return thisAddr;
   }
 
   bool isVirtualOffsetNeededForVTableField(CIRGenFunction &cgf,
                                            CIRGenFunction::VPtr vptr) override 
{
+    cgf.cgm.errorNYI("isVirtualOffsetNeededForVTableField: MSVC ABI");
     return false;
   }
 
@@ -152,18 +169,15 @@ class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
   }
 
   void emitVirtualInheritanceTables(const CXXRecordDecl *rd) override {
-    if (rd->getNumVBases())
-      cgm.errorNYI(rd->getSourceRange(),
-                   "emitVirtualInheritanceTables: MSVC VBTables");
+    cgm.errorNYI(rd->getSourceRange(),
+                 "emitVirtualInheritanceTables: MSVC ABI");
   }
 
   void
   initializeHiddenVirtualInheritanceMembers(CIRGenFunction &cgf,
                                             const CXXRecordDecl *rd) override {
-    if (rd->getNumVBases())
-      cgf.cgm.errorNYI(
-          rd->getSourceRange(),
-          "initializeHiddenVirtualInheritanceMembers: vbptr stores");
+    cgf.cgm.errorNYI(rd->getSourceRange(),
+                     "initializeHiddenVirtualInheritanceMembers: MSVC ABI");
   }
 
   mlir::Value
@@ -183,12 +197,14 @@ class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
   mlir::Value performThisAdjustment(CIRGenFunction &cgf, Address thisAddr,
                                     const CXXRecordDecl *unadjustedClass,
                                     const ThunkInfo &ti) override {
+    cgf.cgm.errorNYI("performThisAdjustment: MSVC ABI");
     return thisAddr.emitRawPointer();
   }
 
   mlir::Value performReturnAdjustment(CIRGenFunction &cgf, Address ret,
                                       const CXXRecordDecl *unadjustedClass,
                                       const ReturnAdjustment &ra) override {
+    cgf.cgm.errorNYI("performReturnAdjustment: MSVC ABI");
     return ret.emitRawPointer();
   }
 
@@ -197,6 +213,8 @@ class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
   }
 
   bool doStructorsInitializeVPtrs(const CXXRecordDecl *vtableClass) override {
+    cgm.errorNYI(vtableClass->getSourceRange(),
+                 "doStructorsInitializeVPtrs: MSVC ABI");
     return false;
   }
 
@@ -204,24 +222,31 @@ class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
 
   bool useThunkForDtorVariant(const CXXDestructorDecl *dtor,
                               CXXDtorType dt) const override {
+    cgm.errorNYI(dtor->getSourceRange(), "useThunkForDtorVariant: MSVC ABI");
     return false;
   }
 
   void setThunkLinkage(cir::FuncOp thunk, bool forVTable, GlobalDecl gd,
                        bool returnAdjustment) override {
-    thunk.setLinkage(cir::GlobalLinkageKind::LinkOnceODRLinkage);
+    cgm.errorNYI(gd.getDecl()->getSourceRange(),
+                 "setThunkLinkage: MSVC ABI");
   }
 
-  llvm::StringRef getPureVirtualCallName() override { return "_purecall"; }
-  llvm::StringRef getDeletedVirtualCallName() override { return "_purecall"; }
+  StringRef getPureVirtualCallName() override { return "_purecall"; }
+  StringRef getDeletedVirtualCallName() override { return "_purecall"; }
 
   bool isZeroInitializable(const MemberPointerType *mpt) override {
+    cgm.errorNYI("isZeroInitializable: MSVC ABI");
     return true;
   }
 
-  bool requiresArrayCookie(const CXXNewExpr *e) override { return false; }
+  bool requiresArrayCookie(const CXXNewExpr *e) override {
+    cgm.errorNYI(e->getSourceRange(), "requiresArrayCookie: MSVC ABI");
+    return false;
+  }
 
   CharUnits getArrayCookieSizeImpl(QualType elementType) override {
+    cgm.errorNYI("getArrayCookieSizeImpl: MSVC ABI");
     return CharUnits::Zero();
   }
 
@@ -232,7 +257,10 @@ class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
     return newPtr;
   }
 
-  bool shouldTypeidBeNullChecked(QualType srcTy) override { return false; }
+  bool shouldTypeidBeNullChecked(QualType srcTy) override {
+    cgm.errorNYI("shouldTypeidBeNullChecked: MSVC ABI");
+    return false;
+  }
 
   mlir::Value emitTypeid(CIRGenFunction &cgf, QualType srcTy, Address thisPtr,
                          mlir::Type typeInfoPtrTy) override {
@@ -265,6 +293,7 @@ class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
   }
 
   CatchTypeInfo getCatchAllTypeInfo() override {
+    cgm.errorNYI("getCatchAllTypeInfo: MSVC ABI");
     return CatchTypeInfo{nullptr, 0};
   }
 
@@ -284,7 +313,9 @@ class CIRGenMicrosoftCXXABI : public CIRGenCXXABI {
   }
 
   void registerGlobalDtor(const VarDecl *vd, cir::FuncOp dtor,
-                          mlir::Value addr) override {}
+                          mlir::Value addr) override {
+    cgm.errorNYI(vd->getSourceRange(), "registerGlobalDtor: MSVC ABI");
+  }
 };
 
 } // namespace

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

Reply via email to