From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 116545 invoked by alias); 22 May 2015 12:15:57 -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 116530 invoked by uid 89); 22 May 2015 12:15:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.4 required=5.0 tests=AWL,BAYES_50,KAM_ASCII_DIVIDERS,KAM_LAZY_DOMAIN_SECURITY,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 22 May 2015 12:15:56 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id A82FD542D9A; Fri, 22 May 2015 14:15:52 +0200 (CEST) Date: Fri, 22 May 2015 12:33:00 -0000 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, rguenther@suse.de Subject: Do not compute alias sets for types that don't need them Message-ID: <20150522121552.GC91616@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-05/txt/msg02101.txt.bz2 Hi, this patch fixes few cases where we compute alias type and don't need to that are found by adding type_with_alias_set_p check to alias.c (I will send this patch separately as there is still one ICE caught by it I believe originating from ipa-icf-gimple, I have more involved fix for that) The point of all this is to check that we don't make bogus querries to alias oracle and don't try to use them somehow - we did in ipa-icf-gimple. This is a bug as the alias oracle gives stupid answers to stupid questions and sometimes think the types conflicts sometimes thinks they doesn't. The other three cases are sort of just pointless computations. Next part I would like to break out is the path computing equivalences considering incomplete types (i.e. where all strucutres are equivalent and so all unions or all functions of a given return value) Bootstrapped/regtested x86_64-linux, OK? Honza * tree-streamer-out.c (pack_ts_type_common_value_fields): Only consider alias set for types that have them. * lto-streamer-out.c (DFS::DFS_write_tree_body): Likewise. * emit-rtl.c (set_mem_attributes_minus_bitpos): Likewise. * ipa-icf-gimple.c (func_checker::compatible_types_p): Likewise. Index: tree-streamer-out.c =================================================================== --- tree-streamer-out.c (revision 223508) +++ tree-streamer-out.c (working copy) @@ -346,6 +346,7 @@ pack_ts_type_common_value_fields (struct alias-set zero to this type. */ bp_pack_var_len_int (bp, (TYPE_ALIAS_SET (expr) == 0 || (!in_lto_p + && type_with_alias_set_p (expr) && get_alias_set (expr) == 0)) ? 0 : -1); } Index: lto-streamer-out.c =================================================================== --- lto-streamer-out.c (revision 223508) +++ lto-streamer-out.c (working copy) @@ -1146,6 +1146,7 @@ hash_tree (struct streamer_tree_cache_d hstate.add_int (TYPE_ALIGN (t)); hstate.add_int ((TYPE_ALIAS_SET (t) == 0 || (!in_lto_p + && type_with_alias_set_p (t) && get_alias_set (t) == 0)) ? 0 : -1); } Index: emit-rtl.c =================================================================== --- emit-rtl.c (revision 223508) +++ emit-rtl.c (working copy) @@ -1787,8 +1787,15 @@ set_mem_attributes_minus_bitpos (rtx ref memset (&attrs, 0, sizeof (attrs)); /* Get the alias set from the expression or type (perhaps using a - front-end routine) and use it. */ - attrs.alias = get_alias_set (t); + front-end routine) and use it. + + We may be called to produce MEM RTX for variable of incomplete type. + This MEM RTX will only be used to produce address of a vairable, so + we do not need to compute alias set. */ + if (!DECL_P (t) || type_with_alias_set_p (TYPE_MAIN_VARIANT (TREE_TYPE (t)))) + attrs.alias = get_alias_set (t); + else + gcc_assert (DECL_P (t) && TREE_ADDRESSABLE (t)); MEM_VOLATILE_P (ref) |= TYPE_VOLATILE (type); MEM_POINTER (ref) = POINTER_TYPE_P (type); Index: ipa-icf-gimple.c =================================================================== --- ipa-icf-gimple.c (revision 223508) +++ ipa-icf-gimple.c (working copy) @@ -274,6 +274,12 @@ func_checker::compatible_types_p (tree t if (!types_compatible_p (t1, t2)) return return_false_with_msg ("types are not compatible"); + /* FIXME: type compatiblity checks for types that are never stored + to memory is not very useful. We should update the code to avoid + calling compatible_types_p on types that will never be used. */ + if (!type_with_alias_set_p (t1) || !type_with_alias_set_p (t2)) + return true; + if (get_alias_set (t1) != get_alias_set (t2)) return return_false_with_msg ("alias sets are different");