[llvm] Update the EBO static_assert to dheck against APFloat::Storage instead of IEEEFloat. (PR #112589)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 16 11:01:40 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-support
Author: Daniel Chen (DanielCChen)
<details>
<summary>Changes</summary>
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
---
Full diff: https://github.com/llvm/llvm-project/pull/112589.diff
2 Files Affected:
- (modified) llvm/include/llvm/ADT/APFloat.h (+1-3)
- (modified) llvm/lib/Support/APFloat.cpp (+5)
``````````diff
diff --git a/llvm/include/llvm/ADT/APFloat.h b/llvm/include/llvm/ADT/APFloat.h
index 97547fb577e0ec..85e17efd1fba8e 100644
--- a/llvm/include/llvm/ADT/APFloat.h
+++ b/llvm/include/llvm/ADT/APFloat.h
@@ -1474,11 +1474,9 @@ class APFloat : public APFloatBase {
friend APFloat frexp(const APFloat &X, int &Exp, roundingMode RM);
friend IEEEFloat;
friend DoubleAPFloat;
+ friend class APFloatEBOChecker;
};
-static_assert(sizeof(APFloat) == sizeof(detail::IEEEFloat),
- "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
``````````
</details>
https://github.com/llvm/llvm-project/pull/112589
More information about the llvm-commits
mailing list