Skip to content

Commit 5c8d305

Browse files
Fix complex types declared using mode TC
This patch reverts incorrect IR introduced in commit d11ec6f [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 d11ec6f 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
1 parent 7011511 commit 5c8d305

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

clang/lib/Basic/TargetInfo.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,11 @@ FloatModeKind TargetInfo::getRealTypeByWidth(unsigned BitWidth,
300300
if (ExplicitType == FloatModeKind::Ibm128)
301301
return hasIbm128Type() ? FloatModeKind::Ibm128
302302
: FloatModeKind::NoFloat;
303-
if (ExplicitType == FloatModeKind::LongDouble)
304-
return ExplicitType;
303+
if (&getLongDoubleFormat() == &llvm::APFloat::PPCDoubleDouble() ||
304+
&getLongDoubleFormat() == &llvm::APFloat::IEEEquad())
305+
return FloatModeKind::LongDouble;
306+
if (hasFloat128Type())
307+
return FloatModeKind::Float128;
305308
break;
306309
}
307310

clang/test/CodeGenCXX/complex128.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-linux-gnu %s -o - | FileCheck %s
2+
3+
// Define __complex128 type corresponding to __float128 (as in GCC headers).
4+
typedef _Complex float __attribute__((mode(TC))) __complex128;
5+
6+
void check() {
7+
// CHECK: alloca { fp128, fp128 }
8+
__complex128 tmp;
9+
}

0 commit comments

Comments
 (0)