public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] drop va_list from formals if requested
@ 2021-07-10  9:43 Alexandre Oliva
  0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2021-07-10  9:43 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e946584ca5a8ebdbe295a7cd69502e72b0dd7061

commit e946584ca5a8ebdbe295a7cd69502e72b0dd7061
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Fri Jul 9 19:54:42 2021 -0300

    drop va_list from formals if requested

Diff:
---
 gcc/ipa-param-manipulation.c | 17 ++++++++++++-----
 gcc/tree-inline.c            |  2 +-
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/gcc/ipa-param-manipulation.c b/gcc/ipa-param-manipulation.c
index 26b02d7aa95..75b5a47a7ae 100644
--- a/gcc/ipa-param-manipulation.c
+++ b/gcc/ipa-param-manipulation.c
@@ -283,14 +283,17 @@ fill_vector_of_new_param_types (vec<tree> *new_types, vec<tree> *otypes,
 
 static tree
 build_adjusted_function_type (tree orig_type, vec<tree> *new_param_types,
-			      bool method2func, bool skip_return)
+			      bool method2func, bool skip_return,
+			      bool skip_valist)
 {
   tree new_arg_types = NULL;
   if (TYPE_ARG_TYPES (orig_type))
     {
       gcc_checking_assert (new_param_types);
-      bool last_parm_void = (TREE_VALUE (tree_last (TYPE_ARG_TYPES (orig_type)))
-			     == void_type_node);
+      bool last_parm_void = (skip_valist
+			     || (TREE_VALUE (tree_last (TYPE_ARG_TYPES
+							(orig_type)))
+				 == void_type_node));
       unsigned len = new_param_types->length ();
       for (unsigned i = 0; i < len; i++)
 	new_arg_types = tree_cons (NULL_TREE, (*new_param_types)[i],
@@ -458,8 +461,10 @@ ipa_param_adjustments::build_new_function_type (tree old_type,
   else
     new_param_types_p = NULL;
 
+  bool skip_valist = m_always_copy_start < 0;
   return build_adjusted_function_type (old_type, new_param_types_p,
-				       method2func_p (old_type), m_skip_return);
+				       method2func_p (old_type), m_skip_return,
+				       skip_valist);
 }
 
 /* Build variant of function decl ORIG_DECL which has no return value if
@@ -1309,8 +1314,10 @@ ipa_param_body_adjustments::modify_formal_parameters ()
      through tree_function_versioning, not when modifying function body
      directly.  */
   gcc_assert (!m_adjustments || !m_adjustments->m_skip_return);
+  bool skip_valist = m_adjustments && m_adjustments->m_always_copy_start < 0;
   tree new_type = build_adjusted_function_type (orig_type, &m_new_types,
-						m_method2func, false);
+						m_method2func, false,
+						skip_valist);
 
   TREE_TYPE (m_fndecl) = new_type;
   DECL_VIRTUAL_P (m_fndecl) = 0;
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index f605e763f4a..0e9bb622421 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -2793,7 +2793,7 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, profile_count count)
   cfun->va_list_fpr_size = src_cfun->va_list_fpr_size;
   cfun->has_nonlocal_label = src_cfun->has_nonlocal_label;
   cfun->calls_eh_return = src_cfun->calls_eh_return;
-  cfun->stdarg = src_cfun->stdarg;
+  cfun->stdarg = src_cfun->stdarg && stdarg_p (TREE_TYPE (new_fndecl));
   cfun->after_inlining = src_cfun->after_inlining;
   cfun->can_throw_non_call_exceptions
     = src_cfun->can_throw_non_call_exceptions;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] drop va_list from formals if requested
@ 2022-04-06 15:02 Alexandre Oliva
  0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2022-04-06 15:02 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:6eb977e04567db1c7acea7b827d467749f437d4e

commit 6eb977e04567db1c7acea7b827d467749f437d4e
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Wed Sep 8 19:13:35 2021 -0300

    drop va_list from formals if requested
    
    I'm working on a feature that involves creating wrappers for some
    functions, using alternate means to pass variable argument lists to
    the wrapped versions.  The split-out (wrapped) function shouldn't be
    stdarg, and though comments in m_always_copy_start in
    ipa_param_adjustments suggested that making it negative would cause
    variable arguments to be dropped, this was not the case, and AFAICT
    there was no way to accomplish that.
    
    Perhaps there was no such intent implied by the comments, but that
    sounded like a reasonable plan to me, so I went ahead an implemented
    it.  With this patch, a negative m_always_copy_start drops the
    variable argument list marker from a cloned function's type, and the
    stdarg flag from the cloned cfun data structure.
    
    
    for  gcc/ChangeLog
    
            * ipa-param-manipulation.c (build_adjusted_function_type): Add
            skip_valist, obey it.
            (ipa_param_adjustments::build_new_function_type): Take
            negative m_always_copy_start as skip_valist.
            (ipa_param_body_adjustmnets::modify_formal_parameters):
            Likewise.
            * tree-inline.c (initialize_cfun): Clear stdarg if function
            type doesn't support it.
            * ipa-strub.c (pass_ipa_strub::execute): Check that stdarg is
            dropped from the clone.

Diff:
---
 gcc/ipa-param-manipulation.cc | 15 ++++++++++-----
 gcc/ipa-strub.cc              |  2 ++
 gcc/tree-inline.cc            |  2 +-
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/gcc/ipa-param-manipulation.cc b/gcc/ipa-param-manipulation.cc
index 38328c3e8d0..5c2d1eb88da 100644
--- a/gcc/ipa-param-manipulation.cc
+++ b/gcc/ipa-param-manipulation.cc
@@ -314,14 +314,16 @@ drop_type_attribute_if_params_changed_p (tree name)
 static tree
 build_adjusted_function_type (tree orig_type, vec<tree> *new_param_types,
 			      bool method2func, bool skip_return,
-			      bool args_modified)
+			      bool skip_valist, bool args_modified)
 {
   tree new_arg_types = NULL;
   if (TYPE_ARG_TYPES (orig_type))
     {
       gcc_checking_assert (new_param_types);
-      bool last_parm_void = (TREE_VALUE (tree_last (TYPE_ARG_TYPES (orig_type)))
-			     == void_type_node);
+      bool last_parm_void = (skip_valist
+			     || (TREE_VALUE (tree_last (TYPE_ARG_TYPES
+							(orig_type)))
+				 == void_type_node));
       unsigned len = new_param_types->length ();
       for (unsigned i = 0; i < len; i++)
 	new_arg_types = tree_cons (NULL_TREE, (*new_param_types)[i],
@@ -548,10 +550,11 @@ ipa_param_adjustments::build_new_function_type (tree old_type,
 	  || get_original_index (index) != (int)index)
 	modified = true;
 
+  bool skip_valist = m_always_copy_start < 0;
 
   return build_adjusted_function_type (old_type, new_param_types_p,
 				       method2func_p (old_type), m_skip_return,
-				       modified);
+				       skip_valist, modified);
 }
 
 /* Build variant of function decl ORIG_DECL which has no return value if
@@ -1571,8 +1574,10 @@ ipa_param_body_adjustments::modify_formal_parameters ()
      through tree_function_versioning, not when modifying function body
      directly.  */
   gcc_assert (!m_adjustments || !m_adjustments->m_skip_return);
+  bool skip_valist = m_adjustments && m_adjustments->m_always_copy_start < 0;
   tree new_type = build_adjusted_function_type (orig_type, &m_new_types,
-						m_method2func, false, modified);
+						m_method2func, false,
+						skip_valist, modified);
 
   TREE_TYPE (m_fndecl) = new_type;
   DECL_VIRTUAL_P (m_fndecl) = 0;
diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc
index 1592e24e2b9..b161a837461 100644
--- a/gcc/ipa-strub.cc
+++ b/gcc/ipa-strub.cc
@@ -2688,6 +2688,8 @@ pass_ipa_strub::execute (function *)
     if (onode->calls_comdat_local)
       nnode->add_to_same_comdat_group (onode);
 
+    gcc_checking_assert (!DECL_STRUCT_FUNCTION (nnode->decl)->stdarg);
+
     set_strub_mode_to (onode, STRUB_WRAPPER);
     set_strub_mode_to (nnode, STRUB_WRAPPED);
 
diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
index ca66a8266b1..28928ec2c86 100644
--- a/gcc/tree-inline.cc
+++ b/gcc/tree-inline.cc
@@ -2822,7 +2822,7 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, profile_count count)
   cfun->va_list_fpr_size = src_cfun->va_list_fpr_size;
   cfun->has_nonlocal_label = src_cfun->has_nonlocal_label;
   cfun->calls_eh_return = src_cfun->calls_eh_return;
-  cfun->stdarg = src_cfun->stdarg;
+  cfun->stdarg = src_cfun->stdarg && stdarg_p (TREE_TYPE (new_fndecl));
   cfun->after_inlining = src_cfun->after_inlining;
   cfun->can_throw_non_call_exceptions
     = src_cfun->can_throw_non_call_exceptions;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] drop va_list from formals if requested
@ 2021-07-10  0:08 Alexandre Oliva
  0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2021-07-10  0:08 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:4adeb16e622d8b8b92fd0611a889108cebddaa3e

commit 4adeb16e622d8b8b92fd0611a889108cebddaa3e
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Fri Jul 9 19:54:42 2021 -0300

    drop va_list from formals if requested

Diff:
---
 gcc/ipa-param-manipulation.c | 17 ++++++++++++-----
 gcc/tree-inline.c            |  2 +-
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/gcc/ipa-param-manipulation.c b/gcc/ipa-param-manipulation.c
index 26b02d7aa95..75b5a47a7ae 100644
--- a/gcc/ipa-param-manipulation.c
+++ b/gcc/ipa-param-manipulation.c
@@ -283,14 +283,17 @@ fill_vector_of_new_param_types (vec<tree> *new_types, vec<tree> *otypes,
 
 static tree
 build_adjusted_function_type (tree orig_type, vec<tree> *new_param_types,
-			      bool method2func, bool skip_return)
+			      bool method2func, bool skip_return,
+			      bool skip_valist)
 {
   tree new_arg_types = NULL;
   if (TYPE_ARG_TYPES (orig_type))
     {
       gcc_checking_assert (new_param_types);
-      bool last_parm_void = (TREE_VALUE (tree_last (TYPE_ARG_TYPES (orig_type)))
-			     == void_type_node);
+      bool last_parm_void = (skip_valist
+			     || (TREE_VALUE (tree_last (TYPE_ARG_TYPES
+							(orig_type)))
+				 == void_type_node));
       unsigned len = new_param_types->length ();
       for (unsigned i = 0; i < len; i++)
 	new_arg_types = tree_cons (NULL_TREE, (*new_param_types)[i],
@@ -458,8 +461,10 @@ ipa_param_adjustments::build_new_function_type (tree old_type,
   else
     new_param_types_p = NULL;
 
+  bool skip_valist = m_always_copy_start < 0;
   return build_adjusted_function_type (old_type, new_param_types_p,
-				       method2func_p (old_type), m_skip_return);
+				       method2func_p (old_type), m_skip_return,
+				       skip_valist);
 }
 
 /* Build variant of function decl ORIG_DECL which has no return value if
@@ -1309,8 +1314,10 @@ ipa_param_body_adjustments::modify_formal_parameters ()
      through tree_function_versioning, not when modifying function body
      directly.  */
   gcc_assert (!m_adjustments || !m_adjustments->m_skip_return);
+  bool skip_valist = m_adjustments && m_adjustments->m_always_copy_start < 0;
   tree new_type = build_adjusted_function_type (orig_type, &m_new_types,
-						m_method2func, false);
+						m_method2func, false,
+						skip_valist);
 
   TREE_TYPE (m_fndecl) = new_type;
   DECL_VIRTUAL_P (m_fndecl) = 0;
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index f605e763f4a..0e9bb622421 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -2793,7 +2793,7 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, profile_count count)
   cfun->va_list_fpr_size = src_cfun->va_list_fpr_size;
   cfun->has_nonlocal_label = src_cfun->has_nonlocal_label;
   cfun->calls_eh_return = src_cfun->calls_eh_return;
-  cfun->stdarg = src_cfun->stdarg;
+  cfun->stdarg = src_cfun->stdarg && stdarg_p (TREE_TYPE (new_fndecl));
   cfun->after_inlining = src_cfun->after_inlining;
   cfun->can_throw_non_call_exceptions
     = src_cfun->can_throw_non_call_exceptions;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [gcc(refs/users/aoliva/heads/testme)] drop va_list from formals if requested
@ 2021-06-28 15:42 Alexandre Oliva
  0 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2021-06-28 15:42 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:0749cb49a28e394161aec95506cc71c9f490c07c

commit 0749cb49a28e394161aec95506cc71c9f490c07c
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Mon Jun 28 12:40:31 2021 -0300

    drop va_list from formals if requested

Diff:
---
 gcc/ipa-param-manipulation.c | 17 ++++++++++++-----
 gcc/tree-inline.c            |  2 +-
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/gcc/ipa-param-manipulation.c b/gcc/ipa-param-manipulation.c
index f2d91476655..85c0f29dcd5 100644
--- a/gcc/ipa-param-manipulation.c
+++ b/gcc/ipa-param-manipulation.c
@@ -209,14 +209,17 @@ fill_vector_of_new_param_types (vec<tree> *new_types, vec<tree> *otypes,
 
 static tree
 build_adjusted_function_type (tree orig_type, vec<tree> *new_param_types,
-			      bool method2func, bool skip_return)
+			      bool method2func, bool skip_return,
+			      bool skip_valist)
 {
   tree new_arg_types = NULL;
   if (TYPE_ARG_TYPES (orig_type))
     {
       gcc_checking_assert (new_param_types);
-      bool last_parm_void = (TREE_VALUE (tree_last (TYPE_ARG_TYPES (orig_type)))
-			     == void_type_node);
+      bool last_parm_void = (skip_valist
+			     || (TREE_VALUE (tree_last (TYPE_ARG_TYPES
+							(orig_type)))
+				 == void_type_node));
       unsigned len = new_param_types->length ();
       for (unsigned i = 0; i < len; i++)
 	new_arg_types = tree_cons (NULL_TREE, (*new_param_types)[i],
@@ -384,8 +387,10 @@ ipa_param_adjustments::build_new_function_type (tree old_type,
   else
     new_param_types_p = NULL;
 
+  bool skip_valist = m_always_copy_start < 0;
   return build_adjusted_function_type (old_type, new_param_types_p,
-				       method2func_p (old_type), m_skip_return);
+				       method2func_p (old_type), m_skip_return,
+				       skip_valist);
 }
 
 /* Build variant of function decl ORIG_DECL which has no return value if
@@ -1257,8 +1262,10 @@ ipa_param_body_adjustments::modify_formal_parameters ()
      through tree_function_versioning, not when modifying function body
      directly.  */
   gcc_assert (!m_adjustments || !m_adjustments->m_skip_return);
+  bool skip_valist = m_adjustments && m_adjustments->m_always_copy_start < 0;
   tree new_type = build_adjusted_function_type (orig_type, &m_new_types,
-						m_method2func, false);
+						m_method2func, false,
+						skip_valist);
 
   TREE_TYPE (m_fndecl) = new_type;
   DECL_VIRTUAL_P (m_fndecl) = 0;
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 9e041ca4d56..9a559847caa 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -2781,7 +2781,7 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, profile_count count)
   cfun->va_list_fpr_size = src_cfun->va_list_fpr_size;
   cfun->has_nonlocal_label = src_cfun->has_nonlocal_label;
   cfun->calls_eh_return = src_cfun->calls_eh_return;
-  cfun->stdarg = src_cfun->stdarg;
+  cfun->stdarg = src_cfun->stdarg && stdarg_p (TREE_TYPE (new_fndecl));
   cfun->after_inlining = src_cfun->after_inlining;
   cfun->can_throw_non_call_exceptions
     = src_cfun->can_throw_non_call_exceptions;


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-06 15:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-10  9:43 [gcc(refs/users/aoliva/heads/testme)] drop va_list from formals if requested Alexandre Oliva
  -- strict thread matches above, loose matches on Subject: below --
2022-04-06 15:02 Alexandre Oliva
2021-07-10  0:08 Alexandre Oliva
2021-06-28 15:42 Alexandre Oliva

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).