[PATCH] D112975: Fix complex types declared using mode TC

Elizabeth Andrews via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 1 17:58:33 PDT 2021


eandrews created this revision.
eandrews added reviewers: qiucf, rjmccall.
eandrews requested review of this revision.

This patch reverts incorrect IR - introduced in commit d11ec6f67e45 <https://reviews.llvm.org/rGd11ec6f67e45c630ab87bfb6010dcc93e89542fc> (https://reviews.llvm.org/rGd11ec6f67e45c630ab87bfb6010dcc93e89542fc) - for complex types declared using __attribute__((mode(TC))). TC mode corresponds to __float128 type.


https://reviews.llvm.org/D112975

Files:
  clang/lib/Basic/TargetInfo.cpp
  clang/test/CodeGenCXX/complex128.cpp


Index: clang/test/CodeGenCXX/complex128.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGenCXX/complex128.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-linux-gnu %s -o - | FileCheck %s
+
+// Define __complex128 type corresponding to __float128 (as in GCC headers).
+typedef _Complex float __attribute__((mode(TC))) __complex128;
+
+void check() {
+  // CHECK: alloca { fp128, fp128 }
+  __complex128 tmp;
+}
Index: clang/lib/Basic/TargetInfo.cpp
===================================================================
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -300,8 +300,11 @@
     if (ExplicitType == FloatModeKind::Ibm128)
       return hasIbm128Type() ? FloatModeKind::Ibm128
                              : FloatModeKind::NoFloat;
-    if (ExplicitType == FloatModeKind::LongDouble)
-      return ExplicitType;
+    if (&getLongDoubleFormat() == &llvm::APFloat::PPCDoubleDouble() ||
+        &getLongDoubleFormat() == &llvm::APFloat::IEEEquad())
+      return FloatModeKind::LongDouble;
+    if (hasFloat128Type())
+      return FloatModeKind::Float128;
     break;
   }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112975.383935.patch
Type: text/x-patch
Size: 1190 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211102/12187e6b/attachment-0001.bin>


More information about the cfe-commits mailing list