Page MenuHomePhabricator

[libc++] Use _Lazy in tuple constructors
Needs ReviewPublic

Authored by ldionne on Aug 23 2022, 3:35 PM.

Details

Reviewers
None
Group Reviewers
Restricted Project
Summary

This reduces the number of instantiations and also avoid blowing up
past the fold-expression limit of Clang.

This is NOT a general statement that we should strive to stay within
Clang's (sometimes way too small) limits, however in this case the
change will reduce the number of template instantiations while at the
same time doing that, which is good.

Diff Detail

Unit TestsFailed

TimeTest
13,410 mslibcxx CI C++14 > llvm-libc++-shared-cfg-in.std/utilities/tuple/tuple_tuple/tuple_cnstr::recursion_depth.pass.cpp
Script: -- : 'COMPILED WITH'; /usr/bin/c++ /home/libcxx-builder/.buildkite-agent/builds/5fdf80bc84fc-1/llvm-project/libcxx-ci/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/recursion_depth.pass.cpp --target=x86_64-unknown-linux-gnu -nostdinc++ -I /home/libcxx-builder/.buildkite-agent/builds/5fdf80bc84fc-1/llvm-project/libcxx-ci/build/generic-cxx14/include/c++/v1 -I /home/libcxx-builder/.buildkite-agent/builds/5fdf80bc84fc-1/llvm-project/libcxx-ci/build/generic-cxx14/include/c++/v1 -I /home/libcxx-builder/.buildkite-agent/builds/5fdf80bc84fc-1/llvm-project/libcxx-ci/libcxx/test/support -std=c++14 -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -lc++experimental -nostdlib++ -L /home/libcxx-builder/.buildkite-agent/builds/5fdf80bc84fc-1/llvm-project/libcxx-ci/build/generic-cxx14/lib -Wl,-rpath,/home/libcxx-builder/.buildkite-agent/builds/5fdf80bc84fc-1/llvm-project/libcxx-ci/build/generic-cxx14/lib -lc++ -pthread -o /home/libcxx-builder/.buildkite-agent/builds/5fdf80bc84fc-1/llvm-project/libcxx-ci/build/generic-cxx14/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/Output/recursion_depth.pass.cpp.dir/t.tmp.exe
14,520 mslibcxx CI C++17 > llvm-libc++-shared-cfg-in.std/utilities/tuple/tuple_tuple/tuple_cnstr::recursion_depth.pass.cpp
Script: -- : 'COMPILED WITH'; /usr/bin/c++ /home/libcxx-builder/.buildkite-agent/builds/996ba8df95e8-1/llvm-project/libcxx-ci/libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/recursion_depth.pass.cpp --target=x86_64-unknown-linux-gnu -nostdinc++ -I /home/libcxx-builder/.buildkite-agent/builds/996ba8df95e8-1/llvm-project/libcxx-ci/build/generic-cxx17/include/c++/v1 -I /home/libcxx-builder/.buildkite-agent/builds/996ba8df95e8-1/llvm-project/libcxx-ci/build/generic-cxx17/include/c++/v1 -I /home/libcxx-builder/.buildkite-agent/builds/996ba8df95e8-1/llvm-project/libcxx-ci/libcxx/test/support -std=c++17 -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_ENABLE_EXPERIMENTAL -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -lc++experimental -nostdlib++ -L /home/libcxx-builder/.buildkite-agent/builds/996ba8df95e8-1/llvm-project/libcxx-ci/build/generic-cxx17/lib -Wl,-rpath,/home/libcxx-builder/.buildkite-agent/builds/996ba8df95e8-1/llvm-project/libcxx-ci/build/generic-cxx17/lib -lc++ -pthread -o /home/libcxx-builder/.buildkite-agent/builds/996ba8df95e8-1/llvm-project/libcxx-ci/build/generic-cxx17/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/Output/recursion_depth.pass.cpp.dir/t.tmp.exe

Event Timeline

ldionne created this revision.Aug 23 2022, 3:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2022, 3:35 PM
ldionne requested review of this revision.Aug 23 2022, 3:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2022, 3:35 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript

Thanks for the fix!

libcxx/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/recursion_depth.pass.cpp
25

I think this would call the move constructor tuple(tuple&&) = default;, which is always going to pass. Those constructors we manually write take a different types of tuple. Would be worth to create a type that is convertible from integral_constant and test tuple of those constructed from LargeTuple?

30

Why does t3 == t4 not work?

31

The new move constructor takes const Tuple<...>&&. It would be good to have a test for that too

LargeTuple t5(std::move(std::as_const(t3)));