diff options
author | Patrick Palka <ppalka@redhat.com> | 2022-03-16 08:25:54 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2022-03-16 08:25:54 -0400 |
commit | e55c5e24b97ad8ddc44588da18e894c139e02c0a (patch) | |
tree | f8de275239ad1c36cf6018e6b2fe264f0cdb3044 /gcc/c-family/c.opt | |
parent | 818e305ea692ebc6578fb40881887d45382f876b (diff) | |
download | gcc-e55c5e24b97ad8ddc44588da18e894c139e02c0a.zip gcc-e55c5e24b97ad8ddc44588da18e894c139e02c0a.tar.gz gcc-e55c5e24b97ad8ddc44588da18e894c139e02c0a.tar.bz2 |
c++: fold calls to std::move/forward [PR96780]
A well-formed call to std::move/forward is equivalent to a cast, but the
former being a function call means the compiler generates debug info,
which persists even after the call gets inlined, for an operation that's
never interesting to debug.
This patch addresses this problem by folding calls to std::move/forward
and other cast-like functions into simple casts as part of the frontend's
general expression folding routine. This behavior is controlled by a
new flag -ffold-simple-inlines, and otherwise by -fno-inline, so that
users can enable this folding with -O0 (which implies -fno-inline).
After this patch with -O2 and a non-checking compiler, debug info size
for some testcases from range-v3 and cmcstl2 decreases by as much as ~10%
and overall compile time and memory usage decreases by ~2%.
PR c++/96780
gcc/ChangeLog:
* doc/invoke.texi (C++ Dialect Options): Document
-ffold-simple-inlines.
gcc/c-family/ChangeLog:
* c.opt: Add -ffold-simple-inlines.
gcc/cp/ChangeLog:
* cp-gimplify.cc (cp_fold) <case CALL_EXPR>: Fold calls to
std::move/forward and other cast-like functions into simple
casts.
gcc/testsuite/ChangeLog:
* g++.dg/opt/pr96780.C: New test.
Diffstat (limited to 'gcc/c-family/c.opt')
-rw-r--r-- | gcc/c-family/c.opt | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt index 9cfd2a6..9a4828e 100644 --- a/gcc/c-family/c.opt +++ b/gcc/c-family/c.opt @@ -1731,6 +1731,10 @@ Support dynamic initialization of thread-local variables in a different translat fexternal-templates C++ ObjC++ WarnRemoved +ffold-simple-inlines +C++ ObjC++ Optimization Var(flag_fold_simple_inlines) +Fold calls to simple inline functions. + ffor-scope C++ ObjC++ WarnRemoved |