From 4ebd491f2aed6d174c976f07d67c4b957f71391d Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sun, 13 Nov 2016 17:23:13 +0000 Subject: [PATCH] ipa-icf.c (sem_function::merge): Do not create a wrapper also if the original function needs a static chain. * ipa-icf.c (sem_function::merge): Do not create a wrapper also if the original function needs a static chain. From-SVN: r242354 --- gcc/ChangeLog | 5 +++++ gcc/ipa-icf.c | 5 +++-- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gnat.dg/lto21.adb | 10 ++++++++++ gcc/testsuite/gnat.dg/lto21_pkg1.ads | 10 ++++++++++ gcc/testsuite/gnat.dg/lto21_pkg2.adb | 30 ++++++++++++++++++++++++++++ gcc/testsuite/gnat.dg/lto21_pkg2.ads | 5 +++++ 7 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/lto21.adb create mode 100644 gcc/testsuite/gnat.dg/lto21_pkg1.ads create mode 100644 gcc/testsuite/gnat.dg/lto21_pkg2.adb create mode 100644 gcc/testsuite/gnat.dg/lto21_pkg2.ads diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 68cc9c6d2d2..0be66610f34 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-11-13 Eric Botcazou + + * ipa-icf.c (sem_function::merge): Do not create a wrapper also if the + original function needs a static chain. + 2016-11-13 David Edelsohn PR target/78336 diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index e8880cb4fe2..1ab67f316a4 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -1186,11 +1186,12 @@ sem_function::merge (sem_item *alias_item) fprintf (dump_file, "Wrapper cannot be created because of COMDAT\n"); } - else if (DECL_STATIC_CHAIN (alias->decl)) + else if (DECL_STATIC_CHAIN (alias->decl) + || DECL_STATIC_CHAIN (original->decl)) { if (dump_file) fprintf (dump_file, - "Can not create wrapper of nested functions.\n"); + "Cannot create wrapper of nested function.\n"); } /* TODO: We can also deal with variadic functions never calling VA_START. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 99bb0d4baea..37ddec7723a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2016-11-13 Eric Botcazou + + * gnat.dg/lto21.adb: New test. + * gnat.dg/lto21_pkg1.ads: New helper. + * gnat.dg/lto21_pkg2.ad[sb]: Likewise. + 2016-11-13 Janus Weil PR fortran/60952 diff --git a/gcc/testsuite/gnat.dg/lto21.adb b/gcc/testsuite/gnat.dg/lto21.adb new file mode 100644 index 00000000000..fe6fb2734b5 --- /dev/null +++ b/gcc/testsuite/gnat.dg/lto21.adb @@ -0,0 +1,10 @@ +-- { dg-do run } +-- { dg-options "-O3 -flto" { target lto } } + +with Lto21_Pkg1; +with Lto21_Pkg2; use Lto21_Pkg2; + +procedure Lto21 is +begin + Proc; +end; diff --git a/gcc/testsuite/gnat.dg/lto21_pkg1.ads b/gcc/testsuite/gnat.dg/lto21_pkg1.ads new file mode 100644 index 00000000000..000a568c6c9 --- /dev/null +++ b/gcc/testsuite/gnat.dg/lto21_pkg1.ads @@ -0,0 +1,10 @@ +with Ada.Containers.Vectors; +with Lto21_Pkg2; + +package Lto21_Pkg1 is + + pragma Suppress (Tampering_Check); + + package Vect1 is new Ada.Containers.Vectors (Positive, Natural); + +end Lto21_Pkg1; diff --git a/gcc/testsuite/gnat.dg/lto21_pkg2.adb b/gcc/testsuite/gnat.dg/lto21_pkg2.adb new file mode 100644 index 00000000000..5d38102d8f2 --- /dev/null +++ b/gcc/testsuite/gnat.dg/lto21_pkg2.adb @@ -0,0 +1,30 @@ +with Ada.Containers; use Ada.Containers; +with Ada.Containers.Hashed_Maps; +with Ada.Containers.Vectors; + +package body Lto21_Pkg2 is + + pragma Suppress (Tampering_Check); + + procedure Proc is + + function Hash (Syd : Natural) return Hash_Type is (Hash_Type'Mod (Syd)); + + package Vect2 is new Vectors (Positive, Natural); + + package Maps is + new Hashed_Maps (Natural, Vect2.Vector, Hash, "=", Vect2."="); + + procedure Nested (M : Maps.Map) is + use Maps; + procedure Inner (Position : Cursor) is null; + begin + Iterate (M, Inner'Access); + end; + + M : Maps.Map; + begin + Nested (M); + end; + +end Lto21_Pkg2; diff --git a/gcc/testsuite/gnat.dg/lto21_pkg2.ads b/gcc/testsuite/gnat.dg/lto21_pkg2.ads new file mode 100644 index 00000000000..935b3b71e8a --- /dev/null +++ b/gcc/testsuite/gnat.dg/lto21_pkg2.ads @@ -0,0 +1,5 @@ +package Lto21_Pkg2 is + + procedure Proc; + +end Lto21_Pkg2; -- 2.30.2