[PATCH] D115337: [X86][clang] Put the update of HasLongDouble into TargetInfo::adjust
Phoebe Wang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 8 05:56:54 PST 2021
pengfei created this revision.
pengfei added reviewers: asavonic, erichkeane, nickdesaulniers, andrew.w.kaylor.
pengfei requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
We found a problem that `-mlong-double-64` doesn't work with `-mno-x87`
due to the flag `HasLongDouble` was set earlier that the option taking
effect. https://godbolt.org/z/9hn8MnPr6
This patch fixes the problem by moving the update of HasLongDouble into
TargetInfo::adjust so that we can update it correctly.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D115337
Files:
clang/include/clang/Basic/TargetInfo.h
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/X86.cpp
clang/test/Sema/x86-no-x87.cpp
clang/test/Sema/x86_64-no-x87.cpp
Index: clang/test/Sema/x86_64-no-x87.cpp
===================================================================
--- clang/test/Sema/x86_64-no-x87.cpp
+++ clang/test/Sema/x86_64-no-x87.cpp
@@ -1,6 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -target-feature -x87 -target-feature -sse -DERROR_LONGDOUBLE -DERROR_NOSSE
// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -target-feature -x87 -DERROR_LONGDOUBLE
// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -DNOERROR
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple x86_64-linux-gnu -mlong-double-64 -DNOERROR
#ifdef NOERROR
// expected-no-diagnostics
Index: clang/test/Sema/x86-no-x87.cpp
===================================================================
--- clang/test/Sema/x86-no-x87.cpp
+++ clang/test/Sema/x86-no-x87.cpp
@@ -1,5 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s -triple i686-linux-gnu -target-feature -x87
// RUN: %clang_cc1 -fsyntax-only -verify %s -triple i686-linux-gnu -DNOERROR
+// RUN: %clang_cc1 -fsyntax-only -verify %s -triple i686-linux-gnu -mlong-double-64 -DNOERROR
#ifdef NOERROR
// expected-no-diagnostics
Index: clang/lib/Basic/Targets/X86.cpp
===================================================================
--- clang/lib/Basic/Targets/X86.cpp
+++ clang/lib/Basic/Targets/X86.cpp
@@ -384,8 +384,8 @@
// FIXME: We should allow long double type on 32-bits to match with GCC.
// This requires backend to be able to lower f80 without x87 first.
- if (!HasX87 && LongDoubleFormat == &llvm::APFloat::x87DoubleExtended())
- HasLongDouble = false;
+ if (HasX87)
+ Has80BitLongDouble = true;
if (SSELevel < SSE1 && getTriple().getArch() == llvm::Triple::x86_64)
HasFPReturn = false;
Index: clang/lib/Basic/TargetInfo.cpp
===================================================================
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -38,6 +38,7 @@
HasFloat16 = false;
HasBFloat16 = false;
HasLongDouble = true;
+ Has80BitLongDouble = false;
HasFPReturn = true;
HasStrictFP = false;
PointerWidth = PointerAlign = 32;
@@ -449,6 +450,9 @@
}
}
+ if (LongDoubleFormat == &llvm::APFloat::x87DoubleExtended())
+ HasLongDouble = Has80BitLongDouble;
+
if (Opts.NewAlignOverride)
NewAlign = Opts.NewAlignOverride * getCharWidth();
Index: clang/include/clang/Basic/TargetInfo.h
===================================================================
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -204,6 +204,7 @@
bool HasBFloat16;
bool HasIbm128;
bool HasLongDouble;
+ bool Has80BitLongDouble;
bool HasFPReturn;
bool HasStrictFP;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115337.392732.patch
Type: text/x-patch
Size: 2743 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211208/17e8a67b/attachment.bin>
More information about the cfe-commits
mailing list