[llvm] [libcxx] [libunwind] [libc++] Allow running the test suite with optimizations (PR #68753)
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/68753 >From 66c95807524dc8371c83e80d6f4ba58056f455af Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Tue, 10 Oct 2023 16:35:11 -0700 Subject: [PATCH 1/2] [libc++] Allow running the test suite with optimizations This patch adds a configuration of the libc++ test suite that enables optimizations when building the tests. It also adds a new CI configuration to exercise this on a regular basis. This is added in the context of [1], which requires building with optimizations in order to hit the bug. [1]: https://github.com/llvm/llvm-project/issues/68552 --- .github/workflows/libcxx-build-and-test.yaml | 1 + .../caches/Generic-optimized-speed.cmake | 4 +++ .../allocator.members/allocate.cxx2a.pass.cpp | 2 +- .../support.dynamic/libcpp_deallocate.sh.cpp | 16 +- .../simd.class/simd_ctor_conversion.pass.cpp | 4 +++ .../path.member/path.assign/move.pass.cpp | 2 +- .../path.member/path.construct/move.pass.cpp | 2 +- .../new.size.replace.indirect.pass.cpp| 2 +- .../new.size.replace.pass.cpp | 2 +- .../new.size_align.replace.indirect.pass.cpp | 6 ++-- ...ze_align_nothrow.replace.indirect.pass.cpp | 6 ++-- .../new.size_align_nothrow.replace.pass.cpp | 6 ++-- ...new.size_nothrow.replace.indirect.pass.cpp | 2 +- .../new.size_nothrow.replace.pass.cpp | 2 +- .../new.size.replace.pass.cpp | 2 +- ...ze_align_nothrow.replace.indirect.pass.cpp | 6 ++-- ...new.size_nothrow.replace.indirect.pass.cpp | 2 +- .../func.wrap.func.alg/swap.pass.cpp | 16 +- .../func.wrap.func.con/F.pass.cpp | 2 +- .../func.wrap.func.con/copy_assign.pass.cpp | 8 ++--- .../func.wrap.func.con/copy_move.pass.cpp | 8 ++--- .../nullptr_t_assign.pass.cpp | 2 +- .../func.wrap.func.mod/swap.pass.cpp | 12 .../make_shared.pass.cpp | 4 +-- libcxx/test/support/count_new.h | 5 libcxx/test/support/test_macros.h | 16 +++--- libcxx/utils/ci/run-buildbot | 5 libcxx/utils/libcxx/test/params.py| 29 ++- libunwind/test/libunwind_02.pass.cpp | 28 ++ libunwind/test/unw_resume.pass.cpp| 2 +- libunwind/test/unwind_leaffunction.pass.cpp | 20 - 31 files changed, 150 insertions(+), 74 deletions(-) create mode 100644 libcxx/cmake/caches/Generic-optimized-speed.cmake diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml index 3fd49541fd7cb2..985790a0ee2361 100644 --- a/.github/workflows/libcxx-build-and-test.yaml +++ b/.github/workflows/libcxx-build-and-test.yaml @@ -161,6 +161,7 @@ jobs: 'generic-no-unicode', 'generic-no-wide-characters', 'generic-no-rtti', + 'generic-optimized-speed', 'generic-static', 'generic-with_llvm_unwinder', # TODO Find a better place for the benchmark and bootstrapping builds to live. They're either very expensive diff --git a/libcxx/cmake/caches/Generic-optimized-speed.cmake b/libcxx/cmake/caches/Generic-optimized-speed.cmake new file mode 100644 index 00..577a5de9f34c53 --- /dev/null +++ b/libcxx/cmake/caches/Generic-optimized-speed.cmake @@ -0,0 +1,4 @@ +set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") +set(LIBCXX_TEST_PARAMS "optimization=speed" CACHE STRING "") +set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "") +set(LIBUNWIND_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "") diff --git a/libcxx/test/libcxx/depr/depr.default.allocator/allocator.members/allocate.cxx2a.pass.cpp b/libcxx/test/libcxx/depr/depr.default.allocator/allocator.members/allocate.cxx2a.pass.cpp index da35465c5295be..f2fb606ee6dbcc 100644 --- a/libcxx/test/libcxx/depr/depr.default.allocator/allocator.members/allocate.cxx2a.pass.cpp +++ b/libcxx/test/libcxx/depr/depr.default.allocator/allocator.members/allocate.cxx2a.pass.cpp @@ -60,7 +60,7 @@ void test_aligned() { { globalMemCounter.last_new_size = 0; globalMemCounter.last_new_align = 0; -T* volatile ap2 = a.allocate(11, (const void*)5); +T* ap2 = a.allocate(11, (const void*)5); DoNotOptimize(ap2); assert(globalMemCounter.checkOutstandingNewEq(1)); assert(globalMemCounter.checkNewCalledEq(1)); diff --git a/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp b/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp index fb56ce4518a718..267f87bd3f6f89 100644 --- a/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp +++ b/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp @@ -187,13 +187,13 @@ void test_allocator_and_new_match() { stats.reset(); #if defined(NO_SIZE) && defined(NO_ALIGN) { -int
[llvm] [libcxx] [libunwind] [libc++] Allow running the test suite with optimizations (PR #68753)
https://github.com/philnik777 edited https://github.com/llvm/llvm-project/pull/68753 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [libcxx] [libunwind] [libc++] Allow running the test suite with optimizations (PR #68753)
https://github.com/philnik777 requested changes to this pull request. https://github.com/llvm/llvm-project/pull/68753 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [libcxx] [libunwind] [libc++] Allow running the test suite with optimizations (PR #68753)
https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/68753 >From 2a5035e7b1db4b77ec30426c988478a35b077b7b Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Tue, 10 Oct 2023 16:35:11 -0700 Subject: [PATCH 1/2] [libc++] Allow running the test suite with optimizations This patch adds a configuration of the libc++ test suite that enables optimizations when building the tests. It also adds a new CI configuration to exercise this on a regular basis. This is added in the context of [1], which requires building with optimizations in order to hit the bug. [1]: https://github.com/llvm/llvm-project/issues/68552 --- .github/workflows/libcxx-build-and-test.yaml | 2 +- .../caches/Generic-optimized-speed.cmake | 4 +++ .../support.dynamic/libcpp_deallocate.sh.cpp | 17 +-- .../path.member/path.assign/move.pass.cpp | 2 +- .../path.member/path.construct/move.pass.cpp | 2 +- .../new.size.replace.indirect.pass.cpp| 3 +- .../new.size.replace.pass.cpp | 3 +- .../new.size_align.replace.indirect.pass.cpp | 7 +++-- ...ze_align_nothrow.replace.indirect.pass.cpp | 7 +++-- .../new.size_align_nothrow.replace.pass.cpp | 7 +++-- ...new.size_nothrow.replace.indirect.pass.cpp | 3 +- .../new.size_nothrow.replace.pass.cpp | 3 +- .../new.size.replace.pass.cpp | 3 +- ...ze_align_nothrow.replace.indirect.pass.cpp | 7 +++-- ...new.size_nothrow.replace.indirect.pass.cpp | 3 +- .../func.wrap.func.alg/swap.pass.cpp | 16 +-- .../func.wrap.func.con/F.pass.cpp | 2 +- .../func.wrap.func.con/copy_assign.pass.cpp | 8 +++--- .../func.wrap.func.con/copy_move.pass.cpp | 8 +++--- .../nullptr_t_assign.pass.cpp | 2 +- .../func.wrap.func.mod/swap.pass.cpp | 12 .../make_shared.pass.cpp | 4 +-- libcxx/test/support/count_new.h | 5 libcxx/test/support/do_not_optimize.h | 28 +++ libcxx/utils/ci/run-buildbot | 5 libcxx/utils/libcxx/test/params.py| 28 ++- libunwind/test/libunwind_02.pass.cpp | 26 + libunwind/test/unw_resume.pass.cpp| 2 +- libunwind/test/unwind_leaffunction.pass.cpp | 20 +++-- 29 files changed, 169 insertions(+), 70 deletions(-) create mode 100644 libcxx/cmake/caches/Generic-optimized-speed.cmake create mode 100644 libcxx/test/support/do_not_optimize.h diff --git a/.github/workflows/libcxx-build-and-test.yaml b/.github/workflows/libcxx-build-and-test.yaml index a649993c65dc42f..f0bfd6db9503d75 100644 --- a/.github/workflows/libcxx-build-and-test.yaml +++ b/.github/workflows/libcxx-build-and-test.yaml @@ -151,6 +151,7 @@ jobs: 'generic-no-tzdb', 'generic-no-unicode', 'generic-no-wide-characters', + 'generic-optimized-speed', 'generic-static', 'generic-with_llvm_unwinder' ] @@ -193,4 +194,3 @@ jobs: **/CMakeError.log **/CMakeOutput.log **/crash_diagnostics/* - diff --git a/libcxx/cmake/caches/Generic-optimized-speed.cmake b/libcxx/cmake/caches/Generic-optimized-speed.cmake new file mode 100644 index 000..577a5de9f34c539 --- /dev/null +++ b/libcxx/cmake/caches/Generic-optimized-speed.cmake @@ -0,0 +1,4 @@ +set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "") +set(LIBCXX_TEST_PARAMS "optimization=speed" CACHE STRING "") +set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "") +set(LIBUNWIND_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "") diff --git a/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp b/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp index fb56ce4518a7182..6e6229b752a7a6e 100644 --- a/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp +++ b/libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp @@ -34,6 +34,7 @@ #include #include +#include "do_not_optimize.h" #include "test_macros.h" TEST_DIAGNOSTIC_PUSH @@ -187,13 +188,13 @@ void test_allocator_and_new_match() { stats.reset(); #if defined(NO_SIZE) && defined(NO_ALIGN) { -int* x = new int(42); +int* x = support::do_not_optimize(new int(42)); delete x; assert(stats.expect_plain()); } stats.reset(); { -AlignedType* a = new AlignedType(); +AlignedType* a = support::do_not_optimize(new AlignedType()); delete a; assert(stats.expect_plain()); } @@ -202,14 +203,14 @@ void test_allocator_and_new_match() { stats.reset(); #if TEST_STD_VER >= 11 { -int* x = new int(42); +int* x = support::do_not_optimize(new int(42)); delete x; assert(stats.expect_plain()); } #endif stats.reset(); { -AlignedType* a = new AlignedType(); +AlignedType* a = support::do_not_optimize(new Align
[llvm] [libcxx] [libunwind] [libc++] Allow running the test suite with optimizations (PR #68753)
https://github.com/philnik777 approved this pull request. https://github.com/llvm/llvm-project/pull/68753 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits