* [Bug ipa/101839] [9/10/11/12 Regression] Hand in C++ code with -fdevirtualize
2021-08-10 7:02 [Bug ipa/101839] New: [9/10/11/12 Regression] Hand in C++ code with -fdevirtualize marxin at gcc dot gnu.org
@ 2021-08-10 7:04 ` marxin at gcc dot gnu.org
2021-08-10 7:09 ` marxin at gcc dot gnu.org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-08-10 7:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2021-08-10
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
With, -O2 -fprofile-generate -fdevirtualize, it started first with
r6-168-g5a33401eabe208e6 which might be a non-culprit commit.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/101839] [9/10/11/12 Regression] Hand in C++ code with -fdevirtualize
2021-08-10 7:02 [Bug ipa/101839] New: [9/10/11/12 Regression] Hand in C++ code with -fdevirtualize marxin at gcc dot gnu.org
2021-08-10 7:04 ` [Bug ipa/101839] " marxin at gcc dot gnu.org
@ 2021-08-10 7:09 ` marxin at gcc dot gnu.org
2021-08-10 7:13 ` [Bug ipa/101839] [9/10/11/12 Regression] Hang " rguenth at gcc dot gnu.org
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-08-10 7:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Apparently, -fprofile-generate is not needed, w/o it it started with the same
revision.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/101839] [9/10/11/12 Regression] Hang in C++ code with -fdevirtualize
2021-08-10 7:02 [Bug ipa/101839] New: [9/10/11/12 Regression] Hand in C++ code with -fdevirtualize marxin at gcc dot gnu.org
2021-08-10 7:04 ` [Bug ipa/101839] " marxin at gcc dot gnu.org
2021-08-10 7:09 ` marxin at gcc dot gnu.org
@ 2021-08-10 7:13 ` rguenth at gcc dot gnu.org
2021-08-10 7:33 ` redi at gcc dot gnu.org
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-08-10 7:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[9/10/11/12 Regression] |[9/10/11/12 Regression]
|Hand in C++ code with |Hang in C++ code with
|-fdevirtualize |-fdevirtualize
Known to fail| |10.3.0, 11.2.1, 7.5.0,
| |9.4.0
Target Milestone|--- |9.5
Priority|P3 |P2
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
BA::fill can be declared virtual without any change (it is implicitely so as
stated by the C++ standard it seems).
With GCC 11 and -O -fdevirtualize the program crashes and we see
void {anonymous}::BA::fill (struct BA * const this, struct Buf & buf)
{
<bb 2> [count: 0]:
__builtin_unreachable ();
which is from
a-t.C.083i.inline:t.C:16:14: optimized: folding virtual function call to
__builtin_unreachable
a-t.C.083i.inline:Introduced new external node (void
__builtin_unreachable()/1356).
a-t.C.083i.inline:t.C:17:14: optimized: folding virtual function call to
__builtin_unreachable
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/101839] [9/10/11/12 Regression] Hang in C++ code with -fdevirtualize
2021-08-10 7:02 [Bug ipa/101839] New: [9/10/11/12 Regression] Hand in C++ code with -fdevirtualize marxin at gcc dot gnu.org
` (2 preceding siblings ...)
2021-08-10 7:13 ` [Bug ipa/101839] [9/10/11/12 Regression] Hang " rguenth at gcc dot gnu.org
@ 2021-08-10 7:33 ` redi at gcc dot gnu.org
2022-05-27 9:45 ` [Bug ipa/101839] [10/11/12/13 " rguenth at gcc dot gnu.org
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-10 7:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839
--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #3)
> BA::fill can be declared virtual without any change (it is implicitely so as
> stated by the C++ standard it seems).
Correct.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/101839] [10/11/12/13 Regression] Hang in C++ code with -fdevirtualize
2021-08-10 7:02 [Bug ipa/101839] New: [9/10/11/12 Regression] Hand in C++ code with -fdevirtualize marxin at gcc dot gnu.org
` (3 preceding siblings ...)
2021-08-10 7:33 ` redi at gcc dot gnu.org
@ 2022-05-27 9:45 ` rguenth at gcc dot gnu.org
2022-06-28 10:45 ` jakub at gcc dot gnu.org
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27 9:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|9.5 |10.4
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9 branch is being closed
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/101839] [10/11/12/13 Regression] Hang in C++ code with -fdevirtualize
2021-08-10 7:02 [Bug ipa/101839] New: [9/10/11/12 Regression] Hand in C++ code with -fdevirtualize marxin at gcc dot gnu.org
` (4 preceding siblings ...)
2022-05-27 9:45 ` [Bug ipa/101839] [10/11/12/13 " rguenth at gcc dot gnu.org
@ 2022-06-28 10:45 ` jakub at gcc dot gnu.org
2022-07-29 12:24 ` rguenth at gcc dot gnu.org
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.4 |10.5
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/101839] [10/11/12/13 Regression] Hang in C++ code with -fdevirtualize
2021-08-10 7:02 [Bug ipa/101839] New: [9/10/11/12 Regression] Hand in C++ code with -fdevirtualize marxin at gcc dot gnu.org
` (5 preceding siblings ...)
2022-06-28 10:45 ` jakub at gcc dot gnu.org
@ 2022-07-29 12:24 ` rguenth at gcc dot gnu.org
2022-08-10 3:53 ` yinyuefengyi at gmail dot com
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-07-29 12:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
Honza?
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/101839] [10/11/12/13 Regression] Hang in C++ code with -fdevirtualize
2021-08-10 7:02 [Bug ipa/101839] New: [9/10/11/12 Regression] Hand in C++ code with -fdevirtualize marxin at gcc dot gnu.org
` (6 preceding siblings ...)
2022-07-29 12:24 ` rguenth at gcc dot gnu.org
@ 2022-08-10 3:53 ` yinyuefengyi at gmail dot com
2022-08-10 13:19 ` hubicka at gcc dot gnu.org
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: yinyuefengyi at gmail dot com @ 2022-08-10 3:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839
--- Comment #8 from Xionghu Luo (luoxhu at gcc dot gnu.org) <yinyuefengyi at gmail dot com> ---
The relationship is:
A A::type
| ------------
| |
BA BA::type CA CA::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, &inserted, can_refer,
&speculation_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;
}
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/101839] [10/11/12/13 Regression] Hang in C++ code with -fdevirtualize
2021-08-10 7:02 [Bug ipa/101839] New: [9/10/11/12 Regression] Hand in C++ code with -fdevirtualize marxin at gcc dot gnu.org
` (7 preceding siblings ...)
2022-08-10 3:53 ` yinyuefengyi at gmail dot com
@ 2022-08-10 13:19 ` hubicka at gcc dot gnu.org
2022-08-10 13:44 ` hubicka at gcc dot gnu.org
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: hubicka at gcc dot gnu.org @ 2022-08-10 13:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839
--- Comment #9 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
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))
3244 skipped = 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.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/101839] [10/11/12/13 Regression] Hang in C++ code with -fdevirtualize
2021-08-10 7:02 [Bug ipa/101839] New: [9/10/11/12 Regression] Hand in C++ code with -fdevirtualize marxin at gcc dot gnu.org
` (8 preceding siblings ...)
2022-08-10 13:19 ` hubicka at gcc dot gnu.org
@ 2022-08-10 13:44 ` hubicka at gcc dot gnu.org
2022-08-12 14:27 ` hubicka at gcc dot gnu.org
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: hubicka at gcc dot gnu.org @ 2022-08-10 13:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839
--- Comment #10 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Created attachment 53430
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53430&action=edit
Patch I am testing
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/101839] [10/11/12/13 Regression] Hang in C++ code with -fdevirtualize
2021-08-10 7:02 [Bug ipa/101839] New: [9/10/11/12 Regression] Hand in C++ code with -fdevirtualize marxin at gcc dot gnu.org
` (9 preceding siblings ...)
2022-08-10 13:44 ` hubicka at gcc dot gnu.org
@ 2022-08-12 14:27 ` hubicka at gcc dot gnu.org
2022-08-15 13:57 ` [Bug ipa/101839] [10/11/12 " marxin at gcc dot gnu.org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: hubicka at gcc dot gnu.org @ 2022-08-12 14:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839
--- Comment #11 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Fixed on mainline with r:0f2c7ccd14a29a8af8318f50b8296098fb0ab218
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/101839] [10/11/12 Regression] Hang in C++ code with -fdevirtualize
2021-08-10 7:02 [Bug ipa/101839] New: [9/10/11/12 Regression] Hand in C++ code with -fdevirtualize marxin at gcc dot gnu.org
` (10 preceding siblings ...)
2022-08-12 14:27 ` hubicka at gcc dot gnu.org
@ 2022-08-15 13:57 ` marxin at gcc dot gnu.org
2023-04-27 13:21 ` [Bug ipa/101839] [10/11 " rguenth at gcc dot gnu.org
2023-07-07 10:40 ` [Bug ipa/101839] [11 " rguenth at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-08-15 13:57 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839
--- Comment #12 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Jan Hubicka from comment #11)
> Fixed on mainline with r:0f2c7ccd14a29a8af8318f50b8296098fb0ab218
g:0f2c7ccd14a29a8af8318f50b8296098fb0ab218
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/101839] [10/11 Regression] Hang in C++ code with -fdevirtualize
2021-08-10 7:02 [Bug ipa/101839] New: [9/10/11/12 Regression] Hand in C++ code with -fdevirtualize marxin at gcc dot gnu.org
` (11 preceding siblings ...)
2022-08-15 13:57 ` [Bug ipa/101839] [10/11/12 " marxin at gcc dot gnu.org
@ 2023-04-27 13:21 ` rguenth at gcc dot gnu.org
2023-07-07 10:40 ` [Bug ipa/101839] [11 " rguenth at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-27 13:21 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to fail| |12.2.0
Known to work| |12.2.1
Summary|[10/11/12 Regression] Hang |[10/11 Regression] Hang in
|in C++ code with |C++ code with
|-fdevirtualize |-fdevirtualize
--- Comment #13 from Richard Biener <rguenth at gcc dot gnu.org> ---
And on the 12 branch with r12-9478-gea162107bb376f
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug ipa/101839] [11 Regression] Hang in C++ code with -fdevirtualize
2021-08-10 7:02 [Bug ipa/101839] New: [9/10/11/12 Regression] Hand in C++ code with -fdevirtualize marxin at gcc dot gnu.org
` (12 preceding siblings ...)
2023-04-27 13:21 ` [Bug ipa/101839] [10/11 " rguenth at gcc dot gnu.org
@ 2023-07-07 10:40 ` rguenth at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101839
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.5 |11.5
--- Comment #14 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.
^ permalink raw reply [flat|nested] 15+ messages in thread