[llvm] r196312 - Fix mingw32 thiscall + sret.

Yaron Keren yaron.keren at gmail.com
Wed Dec 4 06:33:15 PST 2013


The ones for for MingW 4.8 ABI, calling member functions with thiscall and
handling structure-returning functions (attached). They were from the bug
database somewhere (I can't find the page right now) and the clang one was
also here:

https://www.mail-archive.com/cfe-commits@cs.uiuc.edu/msg85231.html




2013/12/4 Rafael EspĂ­ndola <rafael.espindola at gmail.com>

> On 4 December 2013 02:25, Yaron Keren <yaron.keren at gmail.com> wrote:
> > Hi Rafael,
> >
> > Isn't your other patch (thiscall methods and struct return) also needed
> for
> > current MingW?
>
> This was the patch for thiscall, which other patch you referring too?
> Since this was not mentioned on the 4.7 release, I assumed that was
> how previous versions of gcc handled thiscall+sret on mingw.
>
> I will build 4.6 to test that.
>
> Cheers,
> Rafael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131204/1c96d5cf/attachment.html>
-------------- next part --------------
Index: lib/Target/X86/X86FastISel.cpp
===================================================================
--- lib/Target/X86/X86FastISel.cpp	(revision 196112)
+++ lib/Target/X86/X86FastISel.cpp	(working copy)
@@ -1863,7 +1863,7 @@
                                            const ImmutableCallSite &CS) {
   if (Subtarget.is64Bit())
     return 0;
-  if (Subtarget.isTargetWindows())
+  if (Subtarget.getTargetTriple().isOSMSVCRT())
     return 0;
   CallingConv::ID CC = CS.getCallingConv();
   if (CC == CallingConv::Fast || CC == CallingConv::GHC)
Index: lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- lib/Target/X86/X86ISelLowering.cpp	(revision 196112)
+++ lib/Target/X86/X86ISelLowering.cpp	(working copy)
@@ -2175,7 +2175,6 @@
 
   MachineFrameInfo *MFI = MF.getFrameInfo();
   bool Is64Bit = Subtarget->is64Bit();
-  bool IsWindows = Subtarget->isTargetWindows();
   bool IsWin64 = Subtarget->isCallingConvWin64(CallConv);
 
   assert(!(isVarArg && IsTailCallConvention(CallConv)) &&
@@ -2420,7 +2419,8 @@
   } else {
     FuncInfo->setBytesToPopOnReturn(0); // Callee pops nothing.
     // If this is an sret function, the return should pop the hidden pointer.
-    if (!Is64Bit && !IsTailCallConvention(CallConv) && !IsWindows &&
+    if (!Is64Bit && !IsTailCallConvention(CallConv) &&
+        !Subtarget->getTargetTriple().isOSMSVCRT() &&
         argsAreStructReturn(Ins) == StackStructReturn)
       FuncInfo->setBytesToPopOnReturn(4);
   }
@@ -2509,7 +2509,6 @@
   MachineFunction &MF = DAG.getMachineFunction();
   bool Is64Bit        = Subtarget->is64Bit();
   bool IsWin64        = Subtarget->isCallingConvWin64(CallConv);
-  bool IsWindows      = Subtarget->isTargetWindows();
   StructReturnType SR = callIsStructReturn(Outs);
   bool IsSibcall      = false;
 
@@ -2903,7 +2902,8 @@
   if (X86::isCalleePop(CallConv, Is64Bit, isVarArg,
                        getTargetMachine().Options.GuaranteedTailCallOpt))
     NumBytesForCalleeToPush = NumBytes;    // Callee pops everything
-  else if (!Is64Bit && !IsTailCallConvention(CallConv) && !IsWindows &&
+  else if (!Is64Bit && !IsTailCallConvention(CallConv) &&
+           !Subtarget->getTargetTriple().isOSMSVCRT() &&
            SR == StackStructReturn)
     // If this is a call to a struct-return function, the callee
     // pops the hidden struct pointer, so we have to push it back.
-------------- next part --------------
Index: lib/AST/ItaniumCXXABI.cpp
===================================================================
--- lib/AST/ItaniumCXXABI.cpp	(revision 196112)
+++ lib/AST/ItaniumCXXABI.cpp	(working copy)
@@ -59,6 +59,10 @@
   }
 
   CallingConv getDefaultMethodCallConv(bool isVariadic) const {
+    const llvm::Triple &T = Context.getTargetInfo().getTriple();
+    if (!isVariadic && T.getOS() == llvm::Triple::MinGW32 &&
+        T.getArch() == llvm::Triple::x86)
+      return CC_X86ThisCall;
     return CC_C;
   }
 


More information about the llvm-commits mailing list