<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Also, don't we usually put ABI changes under an ABI compatibility check?  This would be making Clang incompatible with itself.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">--paulr<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></a></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> cfe-commits [mailto:cfe-commits-bounces@lists.llvm.org]
<b>On Behalf Of </b>Richard Trieu via cfe-commits<br>
<b>Sent:</b> Tuesday, October 30, 2018 10:16 PM<br>
<b>To:</b> Reid Kleckner<br>
<b>Cc:</b> cfe-commits<br>
<b>Subject:</b> Re: r345676 - [Win64] Handle passing i128 by value<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">I have reverted this in r345691 because it caused test CodeGen/mingw-long-double.c to start failing.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">Command Output (stderr):<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">--<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">/usr/local/google/clang/install/llvm/tools/clang/test/CodeGen/mingw-long-double.c:36:11: error: MSC64: expected string not found in input<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">// MSC64: define dso_local double @TestLD(double %x)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">          ^<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><stdin>:12:1: note: scanning from here<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">; Function Attrs: noinline nounwind optnone<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">^<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><stdin>:35:1: note: possible intended match here<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">define dso_local void @TestLDC({ double, double }* noalias sret %agg.result, { double, double }* %x) #2 {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">^<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">--<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I suspect your patch has changed the type of "double" to a different floating point type, causing the failure.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Tue, Oct 30, 2018 at 5:00 PM Reid Kleckner via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Author: rnk<br>
Date: Tue Oct 30 16:58:41 2018<br>
New Revision: 345676<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=345676&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=345676&view=rev</a><br>
Log:<br>
[Win64] Handle passing i128 by value<br>
<br>
For arguments, pass it indirectly, since the ABI doc says pretty clearly<br>
that arguments larger than 8 bytes are passed indirectly. This makes<br>
va_list handling easier, anyway.<br>
<br>
When returning, GCC returns in XMM0, and we match them.<br>
<br>
Fixes PR39492.<br>
<br>
Added:<br>
    cfe/trunk/test/CodeGen/win64-i128.c<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/TargetInfo.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=345676&r1=345675&r2=345676&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=345676&r1=345675&r2=345676&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Oct 30 16:58:41 2018<br>
@@ -3944,18 +3944,39 @@ ABIArgInfo WinX86_64ABIInfo::classify(Qu<br>
     return ABIArgInfo::getDirect(llvm::IntegerType::get(getVMContext(), Width));<br>
   }<br>
<br>
-  // Bool type is always extended to the ABI, other builtin types are not<br>
-  // extended.<br>
-  const BuiltinType *BT = Ty->getAs<BuiltinType>();<br>
-  if (BT && BT->getKind() == BuiltinType::Bool)<br>
-    return ABIArgInfo::getExtend(Ty);<br>
-<br>
-  // Mingw64 GCC uses the old 80 bit extended precision floating point unit. It<br>
-  // passes them indirectly through memory.<br>
-  if (IsMingw64 && BT && BT->getKind() == BuiltinType::LongDouble) {<br>
-    const llvm::fltSemantics *LDF = &getTarget().getLongDoubleFormat();<br>
-    if (LDF == &llvm::APFloat::x87DoubleExtended())<br>
-      return ABIArgInfo::getIndirect(Align, /*ByVal=*/false);<br>
+  if (const BuiltinType *BT = Ty->getAs<BuiltinType>()) {<br>
+    switch (BT->getKind()) {<br>
+    case BuiltinType::Bool:<br>
+      // Bool type is always extended to the ABI, other builtin types are not<br>
+      // extended.<br>
+      return ABIArgInfo::getExtend(Ty);<br>
+<br>
+    case BuiltinType::LongDouble:<br>
+      // Mingw64 GCC uses the old 80 bit extended precision floating point<br>
+      // unit. It passes them indirectly through memory.<br>
+      if (IsMingw64) {<br>
+        const llvm::fltSemantics *LDF = &getTarget().getLongDoubleFormat();<br>
+        if (LDF == &llvm::APFloat::x87DoubleExtended())<br>
+          return ABIArgInfo::getIndirect(Align, /*ByVal=*/false);<br>
+        break;<br>
+      }<br>
+<br>
+    case BuiltinType::Int128:<br>
+    case BuiltinType::UInt128:<br>
+      // If it's a parameter type, the normal ABI rule is that arguments larger<br>
+      // than 8 bytes are passed indirectly. GCC follows it. We follow it too,<br>
+      // even though it isn't particularly efficient.<br>
+      if (!IsReturnType)<br>
+        return ABIArgInfo::getIndirect(Align, /*ByVal=*/false);<br>
+<br>
+      // Mingw64 GCC returns i128 in XMM0. Coerce to v2i64 to handle that.<br>
+      // Clang matches them for compatibility.<br>
+      return ABIArgInfo::getDirect(<br>
+          llvm::VectorType::get(llvm::Type::getInt64Ty(getVMContext()), 2));<br>
+<br>
+    default:<br>
+      break;<br>
+    }<br>
   }<br>
<br>
   return ABIArgInfo::getDirect();<br>
<br>
Added: cfe/trunk/test/CodeGen/win64-i128.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/win64-i128.c?rev=345676&view=auto" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/win64-i128.c?rev=345676&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGen/win64-i128.c (added)<br>
+++ cfe/trunk/test/CodeGen/win64-i128.c Tue Oct 30 16:58:41 2018<br>
@@ -0,0 +1,16 @@<br>
+// RUN: %clang_cc1 -triple x86_64-windows-gnu -emit-llvm -o - %s \<br>
+// RUN:    | FileCheck %s --check-prefix=GNU64<br>
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -emit-llvm -o - %s \<br>
+// RUN:    | FileCheck %s --check-prefix=MSC64<br>
+<br>
+typedef int int128_t __attribute__((mode(TI)));<br>
+<br>
+int128_t foo() { return 0; }<br>
+<br>
+// GNU64: define dso_local <2 x i64> @foo()<br>
+// MSC64: define dso_local <2 x i64> @foo()<br>
+<br>
+int128_t bar(int128_t a, int128_t b) { return a * b; }<br>
+<br>
+// GNU64: define dso_local <2 x i64> @bar(i128*, i128*)<br>
+// MSC64: define dso_local <2 x i64> @bar(i128*, i128*)<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</div>
</body>
</html>