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

--- Comment #3 from Martin Jambor <jamborm at gcc dot gnu.org> ---
OK, so after looking into this (and CHKP) a bit more, this is only one
of many issues with costant propagating into CHKP functions and
thunks.  In fact, there is an attempt to disable that in
propagate_constants_accross_call but it fails because Honza made
IPA-CP also clone for removal useless parameters.  Which is something
we should not do if the function's signature cannot be changed.  So
the correct fix to this seems to be the following, which I will submit
to the mailing list after testing:

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 782df71..d99e69c 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -2518,7 +2518,8 @@ estimate_local_effects (struct cgraph_node *node)
   known_aggs_ptrs = agg_jmp_p_vec_for_t_vec (known_aggs);
   int devirt_bonus = devirtualization_time_bonus (node, known_csts,
                                           known_contexts, known_aggs_ptrs);
-  if (always_const || devirt_bonus || removable_params_cost)
+  if (always_const || devirt_bonus
+      || (removable_params_cost && node->local.can_change_signature))
     {
       struct caller_statistics stats;
       inline_hints hints;

Reply via email to