[llvm] Update the EBO static_assert to dheck against APFloat::Storage instead of IEEEFloat. (PR #112589)
Daniel Chen via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 16 11:01:05 PDT 2024
https://github.com/DanielCChen created https://github.com/llvm/llvm-project/pull/112589
The addition of the the following code in commit https://github.com/llvm/llvm-project/commit/6004f5550c8032f4c632cdbf5dbc0894bb33e51f#diff-3ec11da67f69353fd755e59cc71f551b5e93773fd4e6f6327c7f1c7074a82709R1474
```
static_assert(sizeof(APFloat) == sizeof(detail::IEEEFloat),
"Empty base class optimization is not performed.");
```
broke our downstream code as not all the members of APFloat is IEEE.
This PR supersedes PR #111780.
We made some changed to our downstream code to accommodate the upstream change.
This PR is to modify the EBO static_assert to check against the `sizeof(APFloat::Storage)` instead of `sizeof(detail::IEEEFloat)`, which seems satisfy both upstream and downstream code.
We also moved the assert to `APFloat.cpp` from the header file as per discussion in PR #111780
@Ariel-Burton
>From e0d2620b9f88c52d302db262c09085c3329baf10 Mon Sep 17 00:00:00 2001
From: cdchen-ca <cdchen at ca.ibm.com>
Date: Wed, 16 Oct 2024 11:03:11 -0400
Subject: [PATCH 1/2] Update the EBO static_assert to dheck against
APFloat::Storage instead of IEEEFloat.
---
llvm/include/llvm/ADT/APFloat.h | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h
index 97547fb577e0ec..ef3ef51dabc35e 100644
--- a/llvm/include/llvm/ADT/APFloat.h
+++ b/llvm/include/llvm/ADT/APFloat.h
@@ -1474,10 +1474,14 @@ class APFloat : public APFloatBase {
friend APFloat frexp(const APFloat &X, int &Exp, roundingMode RM);
friend IEEEFloat;
friend DoubleAPFloat;
+ friend class APFloatEBOChecker;
+};
+
+class APFloatEBOChecker {
+ static_assert(sizeof(APFloat) == sizeof(APFloat::U),
+ "Empty base class optimization is not performed.");
};
-static_assert(sizeof(APFloat) == sizeof(detail::IEEEFloat),
- "Empty base class optimization is not performed.");
/// See friend declarations above.
///
>From 6952f51d4254e5f50ccf7bc46f7a4cb1a07fc4f8 Mon Sep 17 00:00:00 2001
From: cdchen-ca <cdchen at ca.ibm.com>
Date: Wed, 16 Oct 2024 13:53:18 -0400
Subject: [PATCH 2/2] Update EBO statich_assert.
---
llvm/include/llvm/ADT/APFloat.h | 6 ------
llvm/lib/Support/APFloat.cpp | 5 +++++
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h
index ef3ef51dabc35e..85e17efd1fba8e 100644
--- a/llvm/include/llvm/ADT/APFloat.h
+++ b/llvm/include/llvm/ADT/APFloat.h
@@ -1477,12 +1477,6 @@ class APFloat : public APFloatBase {
friend class APFloatEBOChecker;
};
-class APFloatEBOChecker {
- static_assert(sizeof(APFloat) == sizeof(APFloat::U),
- "Empty base class optimization is not performed.");
-};
-
-
/// See friend declarations above.
///
/// These additional declarations are required in order to compile LLVM with IBM
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index a33b6c4a6ddc63..f48c82b6afdd89 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -99,6 +99,11 @@ enum class fltNanEncoding {
NegativeZero,
};
+class APFloatEBOChecker {
+ static_assert(sizeof(APFloat) == sizeof(APFloat::U),
+ "Empty base class optimization is not performed.");
+};
+
/* Represents floating point arithmetic semantics. */
struct fltSemantics {
/* The largest E such that 2^E is representable; this matches the
More information about the llvm-commits
mailing list