From patchwork Tue Oct 28 16:14:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 404287 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 DCA8B140076 for ; Wed, 29 Oct 2014 03:15:08 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=yQ2YJkuHPLCRbi2UrCGCywBfgLCUshrIMtNu61iDMJQMMNlPz29fg W0n68blPOgsbHEq73JVNteTQpYQ6qd+XY1eDXRwY0SLxRTIPmnv/4hKZagb7foRS ZjnjN0rZdTYrNAcs+R+E4r9WPe9ZhOlKjQG2siRFs+Dbh7NctOkwBw= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=UOvmx1Bum8wT1WyxwZrO+3jg3iY=; b=juzudPv6zKmhnoPxX9jE Qq+z9taVk4Dv5uhoCFNspZDzgJOT3DIqjc2W6Mh+oEh5fyArVaxcLXrfKnAflVnw MiPLlNbjKhJP/UYV7Ydd5Z0GayOJsETImzU6oBJLdwzuupJh3uAfmDbJczUMMIFq nuwvg0wASFAUspSJ2BJoNGw= Received: (qmail 5866 invoked by alias); 28 Oct 2014 16:15: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 5803 invoked by uid 89); 28 Oct 2014 16:14:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f169.google.com Received: from mail-pd0-f169.google.com (HELO mail-pd0-f169.google.com) (209.85.192.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 28 Oct 2014 16:14:58 +0000 Received: by mail-pd0-f169.google.com with SMTP id y10so979133pdj.28 for ; Tue, 28 Oct 2014 09:14:56 -0700 (PDT) X-Received: by 10.67.30.72 with SMTP id kc8mr4469726pad.13.1414512895915; Tue, 28 Oct 2014 09:14:55 -0700 (PDT) Received: from msticlxl57.ims.intel.com (fmdmzpr03-ext.fm.intel.com. [192.55.54.38]) by mx.google.com with ESMTPSA id pw10sm2021542pbc.93.2014.10.28.09.14.54 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 28 Oct 2014 09:14:55 -0700 (PDT) Date: Tue, 28 Oct 2014 19:14:47 +0300 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH, IPA ICF] Fix PR63664, PR63574 (segfault in ipa-icf pass) Message-ID: <20141028161430.GA61766@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Hi, This patch fixes PR63664 and PR63574. Problem is in NULL types for labels not handled by ICF properly. I assume it is OK for labels to have NULL type and added check into ICF rather then fixed label generation. Bootstrapped and checked on linux-x86_64. OK for trunk? Thanks, Ilya --- gcc/ 2014-10-28 Ilya Enkovich PR ipa/63664 PR bootstrap/63574 * ipa-icf-gimple.c (func_checker::compatible_types_p): Allow NULL args. gcc/testsuite/ 2014-10-28 Ilya Enkovich PR ipa/63664 * gcc.dg/ipa/pr63664.C: New. diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c index 1369b74..afc0eeb 100644 --- a/gcc/ipa-icf-gimple.c +++ b/gcc/ipa-icf-gimple.c @@ -169,6 +169,11 @@ bool func_checker::compatible_types_p (tree t1, tree t2, bool compare_polymorphic, bool first_argument) { + if (!t1 && !t2) + return true; + else if (!t1 || !t2) + return false; + if (TREE_CODE (t1) != TREE_CODE (t2)) return return_false_with_msg ("different tree types"); diff --git a/gcc/testsuite/gcc.dg/ipa/pr63664.C b/gcc/testsuite/gcc.dg/ipa/pr63664.C new file mode 100644 index 0000000..31d96d4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/ipa/pr63664.C @@ -0,0 +1,43 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +class test { + public: + test (int val, int *p) + { + int_val = *p; + bool_val = (val != int_val); + } + + ~test () + { + if (!bool_val) + return; + } + + int get_int_val () const { return int_val; } + + private: + bool bool_val; + int int_val; +}; + +static int __attribute__ ((noinline)) +f1 (int i, int *p) +{ + test obj (i, p); + return obj.get_int_val (); +} + +static int __attribute__ ((noinline)) +f2 (int i, int *p) +{ + test obj (i, p); + return obj.get_int_val (); +} + +int +f (int i, int *p) +{ + return f1 (i, p) + f2 (i, p); +}