From patchwork Sat Jan 10 09:03:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gang X-Patchwork-Id: 427332 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 9ABB7140187 for ; Sat, 10 Jan 2015 19:57:00 +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 :message-id:date:from:mime-version:to:cc:subject:content-type :content-transfer-encoding; q=dns; s=default; b=JW3/hLK2g74SMKXA dbrCs9BjBWkNSEf2hrmTKd3JTUInCJ12TsEtxV8v0SvOM9c5IgcaNnE1N3kwWsBR PcmnzHtyLyjPr0JixXfjomy0/qeX320G+s1kJKiuCVx24R0NQLZCHosVisymYHRn L415fka3FIULu4N8EL9wx35yz4k= 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 :content-transfer-encoding; s=default; bh=5D+qPuaAPINCGGYlN+STSl aEJ2Y=; b=N6wYaDfR1C8pDUPijpkF56f/NwyrH+OfTYLFfjyLtyNXzA8JyC6oD/ Bau9nTHQOBFNi3bcxiZt1U1n3PtAbgOVOveOl1+FnXitol70K/ijxOmrrrngVoOP EuIFEQpykn0F75KWOcD6FFYlydlpaKYI0pvTdgBoBnuikLFJiuncI= Received: (qmail 27021 invoked by alias); 10 Jan 2015 08:56:51 -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 27003 invoked by uid 89); 10 Jan 2015 08:56:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL, BAYES_00, UNPARSEABLE_RELAY autolearn=ham version=3.3.2 X-HELO: out1134-186.mail.aliyun.com Received: from out1134-186.mail.aliyun.com (HELO out1134-186.mail.aliyun.com) (42.120.134.186) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 10 Jan 2015 08:56:41 +0000 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.07426209|-1; FP=0|0|0|0|0|-1|-1|-1; HT=r41g03024; MF=gang.chen@sunrus.com.cn; PH=DS; RN=3; RT=3; SR=0; Received: from ShengShiZhuChengdeMacBook-Pro.local(mailfrom:gang.chen@sunrus.com.cn ip:223.72.65.56) by smtp.aliyun-inc.com(10.194.100.35); Sat, 10 Jan 2015 16:56:29 +0800 Message-ID: <54B0EAFC.5030009@sunrus.com.cn> Date: Sat, 10 Jan 2015 17:03:56 +0800 From: Chen Gang S User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Jeff Law , "joseph@codesourcery.com >> Joseph S. Myers" CC: gcc-patches List Subject: [PATCH] ipa-icf.c: Fix issues generated by original latest commit The related commit is "275e275 IPA ICF: target and optimization flags comparison.". For sem_function::equals_private(), fix the typo issue, and for target_opts_for_fn(), fix access NULL issue. For cross compiling h8300, it will cause the issue below: [root@localhost h8300]# cat fp-bit.i __inline__ static int a (int x) { return __builtin_expect (x == 0, 0); } __inline__ static int b (int x) { return __builtin_expect (x == 1, 0); } __attribute__ ((__always_inline__)) int c (int x, int y) { if (a (x)) return x; if (b (x)) return x; return y; } [root@localhost h8300]# /upstream/build-gcc-h8300/gcc/cc1 -O2 fp-bit.i -o test.s a b c Analyzing compilation unit fp-bit.i:11:41: warning: always_inline function might not be inlinable [-Wattributes] __attribute__ ((__always_inline__)) int c (int x, int y) ^ Performing interprocedural optimizations <*free_lang_data> fp-bit.i:18:1: internal compiler error: Segmentation fault } ^ 0xa11f0e crash_signal ../../gcc/gcc/toplev.c:372 0xda33e7 tree_check ../../gcc/gcc/tree.h:2769 0xda33e7 target_opts_for_fn ../../gcc/gcc/tree.h:4643 0xda33e7 ipa_icf::sem_function::equals_private(ipa_icf::sem_item*, hash_map&) ../../gcc/gcc/ipa-icf.c:438 0xda4023 ipa_icf::sem_function::equals(ipa_icf::sem_item*, hash_map&) ../../gcc/gcc/ipa-icf.c:393 0xda6472 ipa_icf::sem_item_optimizer::subdivide_classes_by_equality(bool) ../../gcc/gcc/ipa-icf.c:1900 0xdaad3c ipa_icf::sem_item_optimizer::execute() ../../gcc/gcc/ipa-icf.c:1719 0xdab961 ipa_icf_driver ../../gcc/gcc/ipa-icf.c:2448 0xdab961 ipa_icf::pass_ipa_icf::execute(function*) ../../gcc/gcc/ipa-icf.c:2496 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. See for instructions. This issue can be found for cross compiling gcc "make all-target-libgcc" under h8300, after fix this issue, it can continue to cross compiling to meet the next building issue for h8300. 2015-01-10 Chen Gang * ipa-icf.c (sem_function::equals_private): Use '&&' instead of '||' to fix typo issue. * gcc/tree.h (target_opts_for_fn): Check NULL_TREE since it can accept and return NULL. --- gcc/ipa-icf.c | 2 +- gcc/tree.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c index 1b76a1d..4ccaf8c 100644 --- a/gcc/ipa-icf.c +++ b/gcc/ipa-icf.c @@ -438,7 +438,7 @@ sem_function::equals_private (sem_item *item, cl_target_option *tar1 = target_opts_for_fn (decl); cl_target_option *tar2 = target_opts_for_fn (m_compared_func->decl); - if (tar1 != NULL || tar2 != NULL) + if (tar1 != NULL && tar2 != NULL) { if (!cl_target_option_eq (tar1, tar2)) { diff --git a/gcc/tree.h b/gcc/tree.h index fc8c8fe..ac27268 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4640,7 +4640,7 @@ target_opts_for_fn (const_tree fndecl) tree fn_opts = DECL_FUNCTION_SPECIFIC_TARGET (fndecl); if (fn_opts == NULL_TREE) fn_opts = target_option_default_node; - return TREE_TARGET_OPTION (fn_opts); + return fn_opts == NULL_TREE ? NULL : TREE_TARGET_OPTION (fn_opts); } /* opt flag for function FNDECL, e.g. opts_for_fn (fndecl, optimize) is