* C++ PATCH: use C++ semantics for inline functions (defined in headers)
@ 2013-03-28 13:48 Gabriel Dos Reis
2013-03-31 10:02 ` Marc Glisse
0 siblings, 1 reply; 3+ messages in thread
From: Gabriel Dos Reis @ 2013-03-28 13:48 UTC (permalink / raw)
To: gcc-patches; +Cc: jason
C++ has a much more predictable semantics for inline functions, so we no
longer need to define them (especially in header files) with the
'static' specifier. The upshot is that when the compiler fails to
inline a call in a given translation unit, it keeps only one copy in the
entire program, instead of multiple copies (as the 'static' specifier
would have implied.)
With this patch, there is 2K reduction in size for cc1plus.
Applying to trunk. Tested on an x86_64-suse-linux.
-- Gaby
2013-03-28 Gabriel Dos Reis <gdr@integrable-solutions.net>
* cp-tree.h (next_aggr_init_expr_arg): Remove static specifier.
(first_aggr_init_expr): Likewise.
(more_aggr_init_expr_args_p): Likewise.
(type_of_this_parm): Likewise.
(class_of_this_parm): Likewise.
* name-lookup.h (get_global_value_if_present): Likewise.
(is_typename_at_global_scope): Likewise.
Index: cp-tree.h
===================================================================
--- cp-tree.h (revision 197194)
+++ cp-tree.h (working copy)
@@ -3026,7 +3026,7 @@
/* Initialize the abstract argument list iterator object ITER with the
arguments from AGGR_INIT_EXPR node EXP. */
-static inline void
+inline void
init_aggr_init_expr_arg_iterator (tree exp,
aggr_init_expr_arg_iterator *iter)
{
@@ -3037,7 +3037,7 @@
/* Return the next argument from abstract argument list iterator object ITER,
and advance its state. Return NULL_TREE if there are no more arguments. */
-static inline tree
+inline tree
next_aggr_init_expr_arg (aggr_init_expr_arg_iterator *iter)
{
tree result;
@@ -3052,7 +3052,7 @@
past and return the first argument. Useful in for expressions, e.g.
for (arg = first_aggr_init_expr_arg (exp, &iter); arg;
arg = next_aggr_init_expr_arg (&iter)) */
-static inline tree
+inline tree
first_aggr_init_expr_arg (tree exp, aggr_init_expr_arg_iterator *iter)
{
init_aggr_init_expr_arg_iterator (exp, iter);
@@ -3061,7 +3061,7 @@
/* Test whether there are more arguments in abstract argument list iterator
ITER, without changing its state. */
-static inline bool
+inline bool
more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
{
return (iter->i < iter->n);
@@ -4905,7 +4905,7 @@
/* Return the type of the `this' parameter of FNTYPE. */
-static inline tree
+inline tree
type_of_this_parm (const_tree fntype)
{
function_args_iterator iter;
@@ -4916,7 +4916,7 @@
/* Return the class of the `this' parameter of FNTYPE. */
-static inline tree
+inline tree
class_of_this_parm (const_tree fntype)
{
return TREE_TYPE (type_of_this_parm (fntype));
Index: name-lookup.h
===================================================================
--- name-lookup.h (revision 197194)
+++ name-lookup.h (working copy)
@@ -347,7 +347,7 @@
/* Set *DECL to the (non-hidden) declaration for ID at global scope,
if present and return true; otherwise return false. */
-static inline bool
+inline bool
get_global_value_if_present (tree id, tree *decl)
{
tree global_value = namespace_binding (id, global_namespace);
@@ -358,7 +358,7 @@
/* True is the binding of IDENTIFIER at global scope names a type. */
-static inline bool
+inline bool
is_typename_at_global_scope (tree id)
{
tree global_value = namespace_binding (id, global_namespace);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: C++ PATCH: use C++ semantics for inline functions (defined in headers)
2013-03-28 13:48 C++ PATCH: use C++ semantics for inline functions (defined in headers) Gabriel Dos Reis
@ 2013-03-31 10:02 ` Marc Glisse
2013-03-31 14:41 ` Gabriel Dos Reis
0 siblings, 1 reply; 3+ messages in thread
From: Marc Glisse @ 2013-03-31 10:02 UTC (permalink / raw)
To: Gabriel Dos Reis; +Cc: gcc-patches
On Thu, 28 Mar 2013, Gabriel Dos Reis wrote:
> C++ has a much more predictable semantics for inline functions, so we no
> longer need to define them (especially in header files) with the
> 'static' specifier. The upshot is that when the compiler fails to
> inline a call in a given translation unit, it keeps only one copy in the
> entire program, instead of multiple copies (as the 'static' specifier
> would have implied.)
>
> With this patch, there is 2K reduction in size for cc1plus.
> Applying to trunk. Tested on an x86_64-suse-linux.
Hi,
the size reduction looks nice, should the same be applied throughout the
compiler? I didn't check if the cxx-conversion branch already does it.
--
Marc Glisse
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: C++ PATCH: use C++ semantics for inline functions (defined in headers)
2013-03-31 10:02 ` Marc Glisse
@ 2013-03-31 14:41 ` Gabriel Dos Reis
0 siblings, 0 replies; 3+ messages in thread
From: Gabriel Dos Reis @ 2013-03-31 14:41 UTC (permalink / raw)
To: gcc-patches
Marc Glisse <marc.glisse@inria.fr> writes:
| On Thu, 28 Mar 2013, Gabriel Dos Reis wrote:
|
| > C++ has a much more predictable semantics for inline functions, so we no
| > longer need to define them (especially in header files) with the
| > 'static' specifier. The upshot is that when the compiler fails to
| > inline a call in a given translation unit, it keeps only one copy in the
| > entire program, instead of multiple copies (as the 'static' specifier
| > would have implied.)
| >
| > With this patch, there is 2K reduction in size for cc1plus.
| > Applying to trunk. Tested on an x86_64-suse-linux.
|
| Hi,
|
| the size reduction looks nice, should the same be applied throughout the
| compiler?
Yes, ideally this should be done throught the entire compiler, except
for the headers/functions that are still shared with the runtime
compiled with a C compiler.
| I didn't check if the cxx-conversion branch already does it.
No, it does not do it -- at least when I checked.
-- Gaby
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-31 14:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-28 13:48 C++ PATCH: use C++ semantics for inline functions (defined in headers) Gabriel Dos Reis
2013-03-31 10:02 ` Marc Glisse
2013-03-31 14:41 ` Gabriel Dos Reis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).