From patchwork Thu Mar 5 13:53:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 446710 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 6AE371400EA for ; Fri, 6 Mar 2015 00:54:08 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=rxV3Y536; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=uur05fVavwjeU6IvQajExrfUuh4jralH+9DTW0B2qmd SpfgrsRuLEroYJ0TTylHocGNB7K21kshzmyhCl8oyaVm61YeCCc9umxlFI6vXp+N eWy2NH6G6XzmjWPpoSVSmz+BgcVPz/jmaD4uB8zr9mN9zRRS/Gac3105etFBt4wE = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=QGrOcP+CkKtdYfmhSEtic1Tute0=; b=rxV3Y536Y9trssvkm vWRmQVMQtuQ30RWTwMwvxunb0ywP/FEj5F2Ge0s+1LHKl2rW8DCi0oon57++9y4Z SAOvhshclQVH/dQbFGFJ1LOPfQXYn4RjGhPzPNHjvOS44VaKK7nCc0MDDUmerPGh 7rGu0rf3Ti8UcDUIDF7GX4jjWk= Received: (qmail 107112 invoked by alias); 5 Mar 2015 13:54:00 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 107096 invoked by uid 89); 5 Mar 2015 13:53:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 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, 05 Mar 2015 13:53:49 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4156CAAD1; Thu, 5 Mar 2015 13:53:45 +0000 (UTC) Message-ID: <54F85FE8.2070104@suse.cz> Date: Thu, 05 Mar 2015 14:53:44 +0100 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 Patches CC: "hubi >> Jan Hubicka" Subject: [PATCH] Fix PR ipa/65318 X-IsSubscribed: yes Hello. This is patch that prevents merge operation for ICF on variables types which are not compatible. Regression tests were run on x86_64-linux-pc. Ready for trunk? Thanks, Martin From b92ec230162b99ff11d4e5688f63ae978e75af12 Mon Sep 17 00:00:00 2001 From: mliska Date: Thu, 5 Mar 2015 13:41:07 +0100 Subject: [PATCH] Fix PR ipa/65318. gcc/ChangeLog: 2015-03-05 Martin Liska PR ipa/65318 * ipa-icf.c (sem_variable::equals): Compare variable types. gcc/testsuite/ChangeLog: 2015-03-05 Martin Liska * gcc.dg/ipa/PR65318.c: New test. --- gcc/ipa-icf.c | 5 +++++ gcc/testsuite/gcc.dg/ipa/PR65318.c | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/ipa/PR65318.c diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index c55a09f..1752e67 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -1501,6 +1501,11 @@ sem_variable::equals (sem_item *item, if (DECL_INITIAL (item->decl) == error_mark_node && in_lto_p) dyn_cast (item->node)->get_constructor (); + /* As seen in PR ipa/65303 we have to compare variable's types. */ + if (!func_checker::compatible_types_p(TREE_TYPE (decl), + TREE_TYPE (item->decl))) + return return_false_with_msg ("variable types are different"); + ret = sem_variable::equals (DECL_INITIAL (decl), DECL_INITIAL (item->node->decl)); if (dump_file && (dump_flags & TDF_DETAILS)) diff --git a/gcc/testsuite/gcc.dg/ipa/PR65318.c b/gcc/testsuite/gcc.dg/ipa/PR65318.c new file mode 100644 index 0000000..f23b3a2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/PR65318.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-ipa-icf-details" } */ + +static short a = 0; +short b = -1; +static unsigned short c = 0; + +int +main () +{ + if (a <= b) + return 1; + + return 0; +} + +/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */ +/* { dg-final { cleanup-ipa-dump "icf" } } */ -- 2.1.2