[PATCH] D35008: [AArch64] Produce the right kind of va_arg for windows

Martin Storsjö via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 5 04:43:37 PDT 2017


mstorsjo created this revision.
Herald added subscribers: kristof.beyls, rengolin, aemerson.

On windows on arm64, the va_list is a plain pointer.


https://reviews.llvm.org/D35008

Files:
  lib/CodeGen/TargetInfo.cpp


Index: lib/CodeGen/TargetInfo.cpp
===================================================================
--- lib/CodeGen/TargetInfo.cpp
+++ lib/CodeGen/TargetInfo.cpp
@@ -4770,10 +4770,11 @@
 
 private:
   ABIKind Kind;
+  bool IsMS;
 
 public:
-  AArch64ABIInfo(CodeGenTypes &CGT, ABIKind Kind)
-    : SwiftABIInfo(CGT), Kind(Kind) {}
+  AArch64ABIInfo(CodeGenTypes &CGT, ABIKind Kind, bool MS)
+      : SwiftABIInfo(CGT), Kind(Kind), IsMS(MS) {}
 
 private:
   ABIKind getABIKind() const { return Kind; }
@@ -4803,9 +4804,12 @@
 
   Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
                     QualType Ty) const override {
-    return isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF)
-                         : EmitAAPCSVAArg(VAListAddr, Ty, CGF);
+    return IsMS ? EmitMSVAArg(CGF, VAListAddr, Ty)
+                : isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF)
+                                : EmitAAPCSVAArg(VAListAddr, Ty, CGF);
   }
+  Address EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr,
+                      QualType Ty) const override;
 
   bool shouldPassIndirectlyForSwift(CharUnits totalSize,
                                     ArrayRef<llvm::Type*> scalars,
@@ -4822,8 +4826,9 @@
 
 class AArch64TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
-  AArch64TargetCodeGenInfo(CodeGenTypes &CGT, AArch64ABIInfo::ABIKind Kind)
-      : TargetCodeGenInfo(new AArch64ABIInfo(CGT, Kind)) {}
+  AArch64TargetCodeGenInfo(CodeGenTypes &CGT, AArch64ABIInfo::ABIKind Kind,
+                           bool IsMS)
+      : TargetCodeGenInfo(new AArch64ABIInfo(CGT, Kind, IsMS)) {}
 
   StringRef getARCRetainAutoreleasedReturnValueMarker() const override {
     return "mov\tfp, fp\t\t# marker for objc_retainAutoreleaseReturnValue";
@@ -5312,6 +5317,14 @@
                           TyInfo, SlotSize, /*AllowHigherAlign*/ true);
 }
 
+Address AArch64ABIInfo::EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr,
+                                    QualType Ty) const {
+  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*indirect*/ false,
+                          CGF.getContext().getTypeInfoInChars(Ty),
+                          CharUnits::fromQuantity(8),
+                          /*allowHigherAlign*/ false);
+}
+
 //===----------------------------------------------------------------------===//
 // ARM ABI Implementation
 //===----------------------------------------------------------------------===//
@@ -8448,7 +8461,8 @@
     if (getTarget().getABI() == "darwinpcs")
       Kind = AArch64ABIInfo::DarwinPCS;
 
-    return SetCGInfo(new AArch64TargetCodeGenInfo(Types, Kind));
+    return SetCGInfo(new AArch64TargetCodeGenInfo(
+        Types, Kind, Triple.getOS() == llvm::Triple::Win32));
   }
 
   case llvm::Triple::wasm32:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35008.105253.patch
Type: text/x-patch
Size: 2797 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170705/2b717d44/attachment-0001.bin>


More information about the cfe-commits mailing list