https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89009
--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
I slightly renamed the functions to have it more readable:
$ cat pr89009.c
void foo();
struct S1 { static void bar(); };
struct __attribute__ ((visibility("default"))) S2: S1 { static void bar(); };
struct S3: S1 { static void bar(); };
struct S4: S3 { static void bar(); };
void S2::bar() { S1::bar(); }
void S3::bar() { S1::bar(); }
void S4::bar() {
foo();
S3::bar(); // MISSING
}
Now ICF does following folding:
Equals called for: static void S3::bar()/1:static void S2::bar()/0 with result:
true
and new localalias is added:
_ZN2S23barEv.localalias/5 (static void S2::_ZN2S23barEv.localalias())
@0x7ffff6b559d8
Type: function definition analyzed alias
Visibility: visibility_specified
References: _ZN2S23barEv/0 (alias)
Referring:
Availability: available
Function flags: icf_merged
Called by: static void S3::bar()/1 (1073741824 (estimated locally),1.00 per
call) (can throw external)
Calls:
and I see the call in S4::f2 is removed here:
pr89009.c.103t.dce2:
;; Function S4::bar (_ZN2S43barEv, funcdef_no=2, decl_uid=2311, cgraph_uid=3,
symbol_order=2)
Marking useful stmt: foo ();
Marking useful stmt: return;
Processing worklist:
processing: return;
processing: foo ();
Eliminating unnecessary statements:
Deleting : S3::bar ();
Removed 1 of 3 statements (33%)
Removed 0 of 0 PHI nodes (0%)
S4::bar ()
{
<bb 2> [local count: 1073741824]:
foo ();
return;
}
Richi do you have any idea what?