-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update the EBO static_assert to dheck against APFloat::Storage instead of IEEEFloat. #112589
Conversation
@llvm/pr-subscribers-llvm-adt Author: Daniel Chen (DanielCChen) ChangesThe addition of the the following code in commit 6004f55#diff-3ec11da67f69353fd755e59cc71f551b5e93773fd4e6f6327c7f1c7074a82709R1474
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. @Ariel-Burton Full diff: https://github.com/llvm/llvm-project/pull/112589.diff 2 Files Affected:
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
|
@llvm/pr-subscribers-llvm-support Author: Daniel Chen (DanielCChen) ChangesThe addition of the the following code in commit 6004f55#diff-3ec11da67f69353fd755e59cc71f551b5e93773fd4e6f6327c7f1c7074a82709R1474
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. @Ariel-Burton Full diff: https://github.com/llvm/llvm-project/pull/112589.diff 2 Files Affected:
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
|
LGTM |
So I still see no reason to update the upstream code to handle this. Your downstream code is different and should change the assert there |
Thanks for the comments. I totally understand your point. |
…OChecker to address review comment.
Reviewers, could you please take some time to review this PR? If no further comments or objections, I would like to merge it early next week. Thanks in advance! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to keep the assertion as-is. It found a legitimate issue with your downstream changes: That they increase the size of APFloat.
You should drop the assertion downstream for now. When you upstream your changes, we can consider whether we are willing to take that size increase or not, and adjust the assertion accordingly at that time.
Ok. That is fair. We will bring it back once we are ready to upstream our code in the future. |
The addition of the the following code in commit 6004f55#diff-3ec11da67f69353fd755e59cc71f551b5e93773fd4e6f6327c7f1c7074a82709R1474
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 ofsizeof(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