<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">I have reverted this in r345691 because it caused test CodeGen/mingw-long-double.c to start failing.</div><div dir="ltr"><br></div><div dir="ltr"><div dir="ltr">Command Output (stderr):</div><div dir="ltr">--</div><div dir="ltr">/usr/local/google/clang/install/llvm/tools/clang/test/CodeGen/mingw-long-double.c:36:11: error: MSC64: expected string not found in input</div><div dir="ltr">// MSC64: define dso_local double @TestLD(double %x)</div><div dir="ltr"> ^</div><div dir="ltr"><stdin>:12:1: note: scanning from here</div><div dir="ltr">; Function Attrs: noinline nounwind optnone</div><div dir="ltr">^</div><div dir="ltr"><stdin>:35:1: note: possible intended match here</div><div dir="ltr">define dso_local void @TestLDC({ double, double }* noalias sret %agg.result, { double, double }* %x) #2 {</div><div dir="ltr">^</div><div dir="ltr"><br></div><div dir="ltr">--</div><div><br></div><div>I suspect your patch has changed the type of "double" to a different floating point type, causing the failure.</div><div><br></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">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:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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" rel="noreferrer" 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" rel="noreferrer" 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" rel="noreferrer" 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" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>