From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26701 invoked by alias); 11 Dec 2014 13:49:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 26691 invoked by uid 89); 11 Dec 2014 13:49:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Thu, 11 Dec 2014 13:49:56 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B05C6AC06 for ; Thu, 11 Dec 2014 13:49:52 +0000 (UTC) Message-ID: <5489A100.90001@suse.cz> Date: Thu, 11 Dec 2014 13:49:00 -0000 From: =?UTF-8?B?TWFydGluIExpxaFrYQ==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: "gcc-pa >> GCC Patches" Subject: [PATCH] Fix for PR ipa/64146 Content-Type: multipart/mixed; boundary="------------010400040200000308010909" X-IsSubscribed: yes X-SW-Source: 2014-12/txt/msg01011.txt.bz2 This is a multi-part message in MIME format. --------------010400040200000308010909 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 210 Hello. In PR64146, for position independent code IPA ICF should be more careful about thunk creation. Patch can bootstrap on x86_64-linux-pc and no new regression was seen. Ready for thunk? Thank you, Martin --------------010400040200000308010909 Content-Type: text/x-patch; name="0001-IPA-ICF-Fix-for-PR-ipa-64146.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-IPA-ICF-Fix-for-PR-ipa-64146.patch" Content-length: 2150 >From e57dbf95cf27c2d5da2322ee75dca6361ab59c8a Mon Sep 17 00:00:00 2001 From: mliska Date: Wed, 10 Dec 2014 14:46:28 +0100 Subject: [PATCH] IPA ICF: Fix for PR ipa/64146 gcc/ChangeLog: 2014-12-10 Martin Liska PR ipa/64146 * ipa-icf.c (sem_function::merge): Check for decl_binds_to_current_def_p is newly added to merge operation. gcc/testsuite/ChangeLog: 2014-12-10 Martin Liska * g++.dg/ipa/pr64146.C: New test. --- gcc/ipa-icf.c | 8 ++++++++ gcc/testsuite/g++.dg/ipa/pr64146.C | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ipa/pr64146.C diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index b193200..91878b2 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -101,6 +101,7 @@ along with GCC; see the file COPYING3. If not see #include #include "ipa-icf-gimple.h" #include "ipa-icf.h" +#include "varasm.h" using namespace ipa_icf_gimple; @@ -624,6 +625,13 @@ sem_function::merge (sem_item *alias_item) return false; } + if (!decl_binds_to_current_def_p (alias->decl)) + { + if (dump_file) + fprintf (dump_file, "Declaration does not bind to currect definition.\n\n"); + return false; + } + if (redirect_callers) { /* If alias is non-overwritable then diff --git a/gcc/testsuite/g++.dg/ipa/pr64146.C b/gcc/testsuite/g++.dg/ipa/pr64146.C new file mode 100644 index 0000000..90c5093 --- /dev/null +++ b/gcc/testsuite/g++.dg/ipa/pr64146.C @@ -0,0 +1,37 @@ +/* { dg-do compile } */ +/* { dg-options "-fpic -fdump-ipa-icf-details -fipa-icf" } */ + +extern "C" const char* +foo() +{ + return "original"; +} + +const char* +test_foo() +{ + return foo(); +} + +extern "C" const char* +bar() +{ + return "original"; +} + +const char* +test_bar() +{ + return bar(); +} + +int main (int argc, char **argv) +{ + test_foo (); + test_bar (); + + return 0; +} + +/* { dg-final { scan-ipa-dump-times "Declaration does not bind to currect definition." 2 "icf" } } */ +/* { dg-final { scan-ipa-dump "Equal symbols: 2" "icf" } } */ -- 2.1.2 --------------010400040200000308010909--