From patchwork Wed Dec 2 08:07:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 551226 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 66D871401DA for ; Wed, 2 Dec 2015 19:07:39 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=rsaQzK2S; 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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=xf30+guR9bLFZbYyqjrbc8AQo3H7Sx9QHPr+R6qCIhRqrvpqBUA32 YXTlIY+rfmRX0Q4aWYfk7CXhRWVhbU6OmCDK1bhHttkdL68eKMHGnRha1MosBwJW 78gWp6Bilu/w0NjhdOFqhmaghce2ipuSqsPBmhKB3rTx8aS2a0tZOA= 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=Fmw8JvMBVc4SNbEHyV4d59/izO4=; b=rsaQzK2SlkIQJYqeGu8u uzh8C/M+oa+9FkyBX22LX/zE6k3D3OW5tyss78ENu+LY6LjVS9izupGZs2XymmY2 aEHeHcIQ3V203lyeFGrF8YWXqWY2FsO8n2g6ALDA45h9WS8WHE2XVroTqzszz+8O WcscxVsHmGSRv5bTrFGIrxk= Received: (qmail 60790 invoked by alias); 2 Dec 2015 08:07:27 -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 60713 invoked by uid 89); 2 Dec 2015 08:07:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, 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; Wed, 02 Dec 2015 08:07:20 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 51E5E543D45; Wed, 2 Dec 2015 09:07:17 +0100 (CET) Date: Wed, 2 Dec 2015 09:07:17 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, rguenther@suse.de Subject: -fstrict-aliasing fixes 5/6: make type system independent of flag_strict_aliasing Message-ID: <20151202080716.GV5527@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi, this patch makes the type system to be unchanged by flag_strict_aliasing. This is needed to prevent optimization loss in flag_strict_aliasing code where some !flag_strict_aliasing code put alias set 0 into a type (this happens in all cases I modified in my original patch). It is also necessary to validate ipa-icf and operand_equal_p transformations to be safe for code transitions !flag_strict_aliasing->flag_strict_aliasing that I wasn to do in the inliner. This patch goes the opposite way than my previous attempt (and is short unlike the explanation ;). Instead of adding extra parameter to get_alias_set it makes get_alias_set do ignore flag_strict_aliasing. To make sure that no TBAA is used when !flag_strict_aliasing I can simply disable alias_set_subset_of and alias_sets_conflict_p which are the only way TBAA oracle can disambiguate items. Next there are cases where optimizations are disabled to keep TBAA right. I audited the code and found only function.c (that uses object_must_conflict for packing) and ipa-icf/fold-const. This patch updates objects_must_conflict_p, fold-const already check flag_strict_aliasing and I did not update ipa-icf because I would have to disable non-strict-aliasing path in the followup patch. I checked that there is no code difference with -fno-strict-aliasing -fno-ipa-icf with this patch on tramp3d and dealII Bootstrapped/regtested x86_64-linux and also lto-bootstraped. Looks OK? * alias.c (alias_set_subset_of, alias_sets_conflict_p, objects_must_conflict_p): Short circuit for !flag_strict_aliasing (get_alias_set): Remove flag_strict_aliasing check. (new_alias_set): Likewise. Index: alias.c =================================================================== --- alias.c (revision 231081) +++ alias.c (working copy) @@ -405,6 +405,10 @@ alias_set_subset_of (alias_set_type set1 { alias_set_entry *ase2; + /* Disable TBAA oracle with !flag_strict_aliasing. */ + if (!flag_strict_aliasing) + return true; + /* Everything is a subset of the "aliases everything" set. */ if (set2 == 0) return true; @@ -466,6 +470,10 @@ alias_sets_conflict_p (alias_set_type se alias_set_entry *ase1; alias_set_entry *ase2; + /* Disable TBAA oracle with !flag_strict_aliasing. */ + if (!flag_strict_aliasing) + return true; + /* The easy case. */ if (alias_sets_must_conflict_p (set1, set2)) return 1; @@ -561,6 +569,9 @@ objects_must_conflict_p (tree t1, tree t { alias_set_type set1, set2; + if (!flag_strict_aliasing) + return 1; + /* If neither has a type specified, we don't know if they'll conflict because we may be using them to store objects of various types, for example the argument and local variables areas of inlined functions. */ @@ -816,10 +827,12 @@ get_alias_set (tree t) { alias_set_type set; - /* If we're not doing any alias analysis, just assume everything - aliases everything else. Also return 0 if this or its type is - an error. */ - if (! flag_strict_aliasing || t == error_mark_node + /* We can not give up with -fno-strict-aliasing because we need to build + proper type representation for possible functions which are build with + -fstirct-aliasing. */ + + /* return 0 if this or its type is an error. */ + if (t == error_mark_node || (! TYPE_P (t) && (TREE_TYPE (t) == 0 || TREE_TYPE (t) == error_mark_node))) return 0; @@ -1085,15 +1098,10 @@ get_alias_set (tree t) alias_set_type new_alias_set (void) { - if (flag_strict_aliasing) - { - if (alias_sets == 0) - vec_safe_push (alias_sets, (alias_set_entry *) NULL); - vec_safe_push (alias_sets, (alias_set_entry *) NULL); - return alias_sets->length () - 1; - } - else - return 0; + if (alias_sets == 0) + vec_safe_push (alias_sets, (alias_set_entry *) NULL); + vec_safe_push (alias_sets, (alias_set_entry *) NULL); + return alias_sets->length () - 1; } /* Indicate that things in SUBSET can alias things in SUPERSET, but that