From patchwork Thu Jun 20 14:15:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1119483 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-503369-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="FjFQRiP2"; dkim-atps=neutral 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 45V3lL4ygpz9s9y for ; Fri, 21 Jun 2019 00:16:13 +1000 (AEST) 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=DapJz3nvP6wHZPk0uBzT9yQEKFen+b7jwQjc6BMbjICh7iReEL5sz 7ZnJrHtraagr6Hn1jqZxYRPjjBi/lcEk2ZnyHSedC0IMTQneRGBkVuvFBlXf/DyX ILC1dFWJTzWzVO+NOfB6roVq1SA5yYMB0RgPYDL+PcMwthuchQRICI= 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=giRHOu//eoAabaWY11dg6ducYGQ=; b=FjFQRiP22qf7Lw3z0PPl BzgGsf0f1sq8a/NEgJpFbPRhhBXzFUQyIyjmsPxLz6BPy1gMVDq1TMBq43twVqfk j/SjKuVx0EhgzWJYygFYDWSYjnrMgyURofU1RB0TOB5v29IoMBim4+JdyNYTBz2c iK1xSryy0ipt1XjW+AGmae0= Received: (qmail 7007 invoked by alias); 20 Jun 2019 14:16:05 -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 6999 invoked by uid 89); 20 Jun 2019 14:16:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, SPAM_SUBJECT1 autolearn=ham version=3.3.1 spammy=sk:aliasin, UD:tree-ssa-alias.c, ref2, sk:alias-a 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 ESMTP; Thu, 20 Jun 2019 14:15:59 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 963F02825DE; Thu, 20 Jun 2019 16:15:56 +0200 (CEST) Date: Thu, 20 Jun 2019 16:15:56 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Drop ref2_is_decl from aliasing_component_refs_p Message-ID: <20190620141556.t4oduxttco4xm7pg@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: NeoMutt/20170113 (1.7.2) Hi, as discussed earlier this patch drops ref2_is_decl from aliasing_component_refs. This parameter makes it to assume that all access path may not continue by reference to DECL which is not true because in gimple memory model we allow to store value of completely unrealted type to it. I have also constructed an (invalid C IMO) testcase (which fails on GCC for ages, but works for ICC) Bootstrapped/regtested x86_64-linux, will commit it shortly. * tree-ssa-alias.c (aliasing_component_refs_p): Remove ref2_is_decl parameter; it has no use in gimple memory model. (indirect_ref_may_alias_decl_p): Update. * gcc.c-torture/execute/alias-access-path-1.c: New testcase. Index: tree-ssa-alias.c =================================================================== --- tree-ssa-alias.c (revision 272507) +++ tree-ssa-alias.c (working copy) @@ -850,8 +850,7 @@ type_has_components_p (tree type) /* Determine if the two component references REF1 and REF2 which are based on access types TYPE1 and TYPE2 and of which at least one is based - on an indirect reference may alias. REF2 is the only one that can - be a decl in which case REF2_IS_DECL is true. + on an indirect reference may alias. REF1_ALIAS_SET, BASE1_ALIAS_SET, REF2_ALIAS_SET and BASE2_ALIAS_SET are the respective alias sets. */ @@ -863,8 +862,7 @@ aliasing_component_refs_p (tree ref1, tree ref2, alias_set_type ref2_alias_set, alias_set_type base2_alias_set, - poly_int64 offset2, poly_int64 max_size2, - bool ref2_is_decl) + poly_int64 offset2, poly_int64 max_size2) { /* If one reference is a component references through pointers try to find a common base and apply offset based disambiguation. This handles @@ -982,7 +980,7 @@ aliasing_component_refs_p (tree ref1, if (TREE_CODE (TREE_TYPE (base1)) == ARRAY_TYPE && (!TYPE_SIZE (TREE_TYPE (base1)) || TREE_CODE (TYPE_SIZE (TREE_TYPE (base1))) != INTEGER_CST - || (ref == base2 && !ref2_is_decl))) + || ref == base2)) { ++alias_stats.aliasing_component_refs_p_may_alias; return true; @@ -1041,7 +1039,7 @@ aliasing_component_refs_p (tree ref1, if (TREE_CODE (TREE_TYPE (base2)) == ARRAY_TYPE && (!TYPE_SIZE (TREE_TYPE (base2)) || TREE_CODE (TYPE_SIZE (TREE_TYPE (base2))) != INTEGER_CST - || (ref == base1 && !ref2_is_decl))) + || ref == base1)) { ++alias_stats.aliasing_component_refs_p_may_alias; return true; @@ -1089,8 +1087,7 @@ aliasing_component_refs_p (tree ref1, return true; } /* If this is ptr vs. decl then we know there is no ptr ... decl path. */ - if (!ref2_is_decl - && compare_type_sizes (TREE_TYPE (ref1), type2) >= 0 + if (compare_type_sizes (TREE_TYPE (ref1), type2) >= 0 && (!end_struct_ref2 || compare_type_sizes (TREE_TYPE (ref1), TREE_TYPE (end_struct_ref2)) >= 0) @@ -1554,13 +1551,7 @@ indirect_ref_may_alias_decl_p (tree ref1 offset1, max_size1, ref2, ref2_alias_set, base2_alias_set, - offset2, max_size2, - /* Only if the other reference is actual - decl we can safely check only toplevel - part of access path 1. */ - same_type_for_tbaa (TREE_TYPE (dbase2), - TREE_TYPE (base2)) - == 1); + offset2, max_size2); return true; } @@ -1675,7 +1666,7 @@ indirect_refs_may_alias_p (tree ref1 ATT offset1, max_size1, ref2, ref2_alias_set, base2_alias_set, - offset2, max_size2, false); + offset2, max_size2); return true; } Index: testsuite/gcc.c-torture/execute/alias-access-path-1.c =================================================================== --- testsuite/gcc.c-torture/execute/alias-access-path-1.c (nonexistent) +++ testsuite/gcc.c-torture/execute/alias-access-path-1.c (working copy) @@ -0,0 +1,19 @@ +/* Test that variable + int val; + may hold value of tyope "struct c" which has same size. + This is valid in GIMPLE memory model. */ + +struct a {int val;} a={1},a2; +struct b {struct a a;}; +int val; +struct c {struct b b;} *cptr=(void *)&val; + +int +main(void) +{ + cptr->b.a=a; + val = 2; + a2=cptr->b.a; + if (a2.val == a.val) + __builtin_abort (); +}