This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug ipa/63851] [5 Regression] ipa-icf miscompiles gfortran.dg/assumed_rank_(8|9|10).f90 at -O2 and above


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]