This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug ipa/63851] [5 Regression] ipa-icf miscompiles gfortran.dg/assumed_rank_(8|9|10).f90 at -O2 and above
- From: "marxin at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 18 Dec 2014 17:31:53 +0000
- Subject: [Bug ipa/63851] [5 Regression] ipa-icf miscompiles gfortran.dg/assumed_rank_(8|9|10).f90 at -O2 and above
- Auto-submitted: auto-generated
- References: <bug-63851-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63851
--- Comment #11 from Martin LiÅka <marxin at gcc dot gnu.org> ---
Hello.
The problem is caused by missing static-chain in newly created GIMPLE_CALL in
expand_thunk:
fpi (struct array7_integer(kind=4) & xx1, struct array7_t & yy1)
{
<bb 2>:
fpa (xx1_2(D), yy1_3(D)); [tail call]
return;
}
where:
main (integer(kind=4) argc, character(kind=1) * * argv)
{
...
fpa (&desc.2, &desc.3); [static-chain: &FRAME.7]
fpi (&desc.4, &desc.5); [static-chain: &FRAME.7]
...
}
I've been testing following patch that stops ICF for such kind of situations:
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index b193200..7faaf56 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -685,6 +685,14 @@ sem_function::merge (sem_item *alias_item)
return 0;
}
+ if (DECL_STATIC_CHAIN (alias->decl))
+ {
+ if (dump_file)
+ fprintf (dump_file, "Thunk creation is risky for static-chain
functions.\n\n");
+
+ return 0;
+ }
+
alias->icf_merged = true;
ipa_merge_profiles (local_original, alias);
alias->create_wrapper (local_original);
Thanks,
Martin