https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125819

Filip Sajdak <filip.sajdak at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |filip.sajdak at gmail dot com

--- Comment #3 from Filip Sajdak <filip.sajdak at gmail dot com> ---
Would a backport of r17-2096-g8ee8f2beab432c to the GCC 16 branch be
considered? Besides the semantics, it is a noticeable compile-time gain for
code that scans the global namespace, and 16.x will be the compiler of most
reflection users for a while.

Measured on aarch64-unknown-linux-gnu with compilers built from source
(--enable-languages=c,c++ --disable-bootstrap --disable-multilib
--enable-checking=release); user-space instructions of cc1plus alone, least of
three runs, minus a twin of the file without the call:

#include <meta>
#include <cstdio>
consteval std::size_t c() { return std::meta::members_of(^^::,
std::meta::access_context::unchecked()).size(); }
constexpr std::size_t n = c();
int main() { std::printf("%zu\n", n); }

compiler                                   members  instructions of the
members_of call
16.2.0 (releases/gcc-16.2.0)                  4142  629 M
16.2.0 + 8ee8f2beab cherry-picked              674  117 M
trunk 9eb44775b9                               674  121 M

The commit cherry-picks onto releases/gcc-16.2.0 without conflicts.

For a real program: one translation unit of a C++26 library that scans
members_of(^^::) to find the functions of the C library it wraps spends 54.09 G
instructions in the front end with 16.2.0 and 49.16 G with only this commit
cherry-picked (-9.1 %).

Tests on 16.2.0 with the cherry-pick: make check-c++
RUNTESTFLAGS="dg.exp=reflect/*" gives 2113 passes and 15 expected failures;
without it the same directory gave 2112 and 15 (the extra pass is the new
members_of17.C). I did not run the full check-c++, and I do not know whether
anyone relies on seeing built-ins in members_of(^^::) on GCC 16.

These measurements were prepared with AI assistance and run on a machine of
mine; no code is proposed here.

Reply via email to