[clang] 5c8d305 - Fix complex types declared using mode TC
Elizabeth Andrews via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 2 12:01:25 PDT 2021
Author: Elizabeth Andrews
Date: 2021-11-02T12:00:26-07:00
New Revision: 5c8d3053fa0c183ea4f908e51a111ada3d4031f2
URL: https://github.com/llvm/llvm-project/commit/5c8d3053fa0c183ea4f908e51a111ada3d4031f2
DIFF: https://github.com/llvm/llvm-project/commit/5c8d3053fa0c183ea4f908e51a111ada3d4031f2.diff
LOG: Fix complex types declared using mode TC
This patch reverts incorrect IR introduced in commit d11ec6f67e45
[Clang] Enable IC/IF mode for __ibm128, for complex types declared
using __attribute__((mode(TC))). TC corresponds to an unspecified
128-bit format, which on some targets is a double-double format
(like __ibm128_t) and on others is float128_t. The bug in d11ec6f67e45
is that long double is only safe to use when it's known to be one of
these formats.
Differential Revision: https://reviews.llvm.org/D112975
Added:
clang/test/CodeGenCXX/complex128.cpp
Modified:
clang/lib/Basic/TargetInfo.cpp
Removed:
################################################################################
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 514893b47b4f4..76855b0c045c5 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -300,8 +300,11 @@ FloatModeKind TargetInfo::getRealTypeByWidth(unsigned BitWidth,
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;
}
diff --git a/clang/test/CodeGenCXX/complex128.cpp b/clang/test/CodeGenCXX/complex128.cpp
new file mode 100644
index 0000000000000..71746314b9d39
--- /dev/null
+++ b/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;
+}
More information about the cfe-commits
mailing list