[Bug ipa/101839] [10/11/12/13 Regression] Hang in C++ code with -fdevirtualize

2022-08-12 Thread hubicka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839

--- Comment #11 from Jan Hubicka  ---
Fixed on mainline with r:0f2c7ccd14a29a8af8318f50b8296098fb0ab218

[Bug ipa/101839] [10/11/12/13 Regression] Hang in C++ code with -fdevirtualize

2022-08-10 Thread hubicka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839

--- Comment #10 from Jan Hubicka  ---
Created attachment 53430
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53430=edit
Patch I am testing

[Bug ipa/101839] [10/11/12/13 Regression] Hang in C++ code with -fdevirtualize

2022-08-10 Thread hubicka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839

--- Comment #9 from Jan Hubicka  ---
Thanks for looking into this.  
What happens here is that we start working from a call where we know that
outer_type is BA. We correctly find the BA::type and notice that it is final
and thus we do not need to look for sucessors to find something.

However we later decide to discard it here:

3241  if (type_possibly_instantiated_p (outer_type->type))
3244skipped = true;

This is trying to check, for anonymous types, the possibility that a given
target is never going to be taken since type was never instantiated. It is true
that BA is not instantiated however its successor is.  So we need to keep track
that we saw FINAL and in that case extend type_possibly_instantiated_p to also
look for all derived types. This is quite ugly mistake I got in as the
possibly_instantiated code was implemented before we got DECL_FINAl flag.

I will prepare patch.

[Bug ipa/101839] [10/11/12/13 Regression] Hang in C++ code with -fdevirtualize

2022-08-09 Thread yinyuefengyi at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839

--- Comment #8 from Xionghu Luo (luoxhu at gcc dot gnu.org)  ---
The relationship is:

A  A::type
| 
| |
BA BA::type   CACA::type
|
CBA CBA::type

class CA and CBA are final, also function CA::type and BA::type are final, then
in function possible_polymorphic_call_targets for "target" BA::type, the
"DECL_FINAL_P (target)" check is not accurate enough, as there may be classes
like CBA derived from BA and have instance that need continue walk recursively
in possible_polymorphic_call_targets_1 to record_target_from_binfo.

  if (target)
{
  /* In the case we get complete method, we don't need 
 to walk derivations.  */
  if (DECL_FINAL_P (target))
context.maybe_derived_type = false;
}

So fix this by belong change only stop walk derivations when target is final
and it's class outer_type->type is also final?

diff --git a/gcc/ipa-devirt.cc b/gcc/ipa-devirt.cc
index 412ca14f66b..77f9b268e86 100644
--- a/gcc/ipa-devirt.cc
+++ b/gcc/ipa-devirt.cc
@@ -3188,7 +3188,9 @@ possible_polymorphic_call_targets (tree otr_type,

   /* In the case we get complete method, we don't need
 to walk derivations.  */
-  if (target && DECL_FINAL_P (target))
+  if (target && TREE_CODE (target) == FUNCTION_DECL && DECL_FINAL_P
(target)
+ && RECORD_OR_UNION_TYPE_P (out er_type->type)
+ && TYPE_FINAL_P (outer_type->type))
context.speculative_maybe_derived_type = false;
   if (type_possibly_instantiated_p (speculative_outer_type->type))
maybe_record_node (nodes, target, , can_refer,
_complete);
@@ -3233,7 +3235,9 @@ possible_polymorphic_call_targets (tree otr_type,
{
  /* In the case we get complete method, we don't need
 to walk derivations.  */
- if (DECL_FINAL_P (target))
+ if (TREE_CODE (target) == FUNCTION_DECL && DECL_FINAL_P (target)
+ && RECORD_OR_UNION_TYPE_P (outer_type->type)
+ && TYPE_FINAL_P (outer_type->type))
context.maybe_derived_type = false;
}

[Bug ipa/101839] [10/11/12/13 Regression] Hang in C++ code with -fdevirtualize

2022-07-29 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839

--- Comment #7 from Richard Biener  ---
Honza?

[Bug ipa/101839] [10/11/12/13 Regression] Hang in C++ code with -fdevirtualize

2022-06-28 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839

Jakub Jelinek  changed:

   What|Removed |Added

   Target Milestone|10.4|10.5

--- Comment #6 from Jakub Jelinek  ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

[Bug ipa/101839] [10/11/12/13 Regression] Hang in C++ code with -fdevirtualize

2022-05-27 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839

Richard Biener  changed:

   What|Removed |Added

   Target Milestone|9.5 |10.4

--- Comment #5 from Richard Biener  ---
GCC 9 branch is being closed