-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
[llvm][cmake] Performing expensive checks requires enabling assert. #80821
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-llvm-ir Author: None (huaatian) ChangesProtection needs to be added to these two unit tests to prevent execution when NDEBUG is defined. Full diff: https://github.com/llvm/llvm-project/pull/80821.diff 2 Files Affected:
diff --git a/llvm/unittests/IR/BasicBlockTest.cpp b/llvm/unittests/IR/BasicBlockTest.cpp
index 3756f227143a50..79bf72bf32f914 100644
--- a/llvm/unittests/IR/BasicBlockTest.cpp
+++ b/llvm/unittests/IR/BasicBlockTest.cpp
@@ -472,6 +472,7 @@ TEST(BasicBlockTest, SpliceInstrRange) {
}
#ifdef EXPENSIVE_CHECKS
+#ifndef NDEBUG
TEST(BasicBlockTest, SpliceEndBeforeBegin) {
LLVMContext Ctx;
std::unique_ptr<Module> M = parseIR(Ctx, R"(
@@ -503,6 +504,7 @@ TEST(BasicBlockTest, SpliceEndBeforeBegin) {
FromI1->getIterator()),
"FromBeginIt not before FromEndIt!");
}
+#endif //NDEBUG
#endif //EXPENSIVE_CHECKS
TEST(BasicBlockTest, EraseRange) {
diff --git a/llvm/unittests/IR/FunctionTest.cpp b/llvm/unittests/IR/FunctionTest.cpp
index 8e77dfbb9dbd99..cb364cf3028871 100644
--- a/llvm/unittests/IR/FunctionTest.cpp
+++ b/llvm/unittests/IR/FunctionTest.cpp
@@ -410,6 +410,7 @@ TEST(FunctionTest, SpliceBBRange) {
}
#ifdef EXPENSIVE_CHECKS
+#ifndef NDEBUG
TEST(FunctionTest, SpliceEndBeforeBegin) {
LLVMContext Ctx;
std::unique_ptr<Module> M = parseIR(Ctx, R"(
@@ -442,6 +443,7 @@ TEST(FunctionTest, SpliceEndBeforeBegin) {
FromBB1->getIterator()),
"FromBeginIt not before FromEndIt!");
}
+#endif //NDEBUG
#endif //EXPENSIVE_CHECKS
TEST(FunctionTest, EraseBBs) {
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
@aeubanks, this issue was discovered in our downstream project. Could you please help review it? Thank you. |
it doesn't really make sense to run expensive checks without asserts, I wouldn't consider that configuration supported |
Thank you for reviewing the code. Indeed, in most cases, when EXPENSIVE_CHECKS is enabled, !NDEBUG is also set. However, I understand that there is no explicit binding between these two situations. For example, in a few cases, I would like to use the checks that report errors with errs(), rather than using assert(). This can be considered as a tolerable medium complexity check. Is this understanding correct? I would appreciate your opinion. |
And also, when the user enables EXPENSIVE_CHECKS and NDEBUG, there is no prompt that such settings are wrong, but these two unit tests will fail. I think this is an issue. |
I don't understand this sentence, can you clarify?
That's fair, it would be good to have a check for this either in CMake or in some header. I would prefer this option. |
So, I added a check in CMake, would that be appropriate? |
please update the commit description and title thanks for doing this! |
When LLVM_ENABLE_EXPENSIVE_CHECKS is ON, LLVM will intercept errors using assert(). So, an explicit check is added.
51b9834
to
f3d32f1
Compare
@huaatian Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested Please check whether problems have been caused by your change specifically, as How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
LLVM will intercept errors using assert() when LLVM_ENABLE_EXPENSIVE_CHECKS is ON. So an explicit check is added.