From patchwork Wed May 27 12:24:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 477087 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 53A551406AA for ; Wed, 27 May 2015 22:25:04 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=vz9RKfLc; 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 :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=VeFMCglO7xiqRRUv8 SJM5FAVjI/s9prbhY6mauRgCxJnIRXDLKMB2egef/B+djL03N9q3CZtj0knsuMpU 8WVAoqUaLodb+hb8sd1/fUeljYxgTvE1GvqXqCxk6r7h7GfXiCp6XtMu/jPDOb3h jrLDbDRGbBFxfyKH8WLwTFULx8= 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:subject:references :in-reply-to:content-type; s=default; bh=asV3XhNYtq6s1uXBxpl6n0L +0s4=; b=vz9RKfLcEKFfjnolHGQ/k+5gfYdytVJF5bnVlcQBQULN8dEeuvUAyx8 JhPNB/Tw6ntxDIPgJTqnB2yhB+jMnFKZDekBHihqvBBa50KK9MMNPeE0RkLci0NV jN5Hnly3sNIGfVmcr9h8nea/UsN+3lEcCaMsxLVsYBHRrZPn2ajc= Received: (qmail 93770 invoked by alias); 27 May 2015 12:24:57 -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 93756 invoked by uid 89); 27 May 2015 12:24:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-qk0-f170.google.com Received: from mail-qk0-f170.google.com (HELO mail-qk0-f170.google.com) (209.85.220.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 27 May 2015 12:24:55 +0000 Received: by qkx62 with SMTP id 62so4091308qkx.3 for ; Wed, 27 May 2015 05:24:53 -0700 (PDT) X-Received: by 10.140.105.198 with SMTP id c64mr39407605qgf.61.1432729493416; Wed, 27 May 2015 05:24:53 -0700 (PDT) Received: from ?IPv6:2601:6:8380:343:a2a8:cdff:fe3e:b48? ([2601:6:8380:343:a2a8:cdff:fe3e:b48]) by mx.google.com with ESMTPSA id q16sm9493940qkq.4.2015.05.27.05.24.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 May 2015 05:24:52 -0700 (PDT) Message-ID: <5565B793.9090709@acm.org> Date: Wed, 27 May 2015 08:24:51 -0400 From: Nathan Sidwell User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Jason Merrill , GCC Patches Subject: Re: [C++/66270] another may_alias crash References: <55638C4E.8040605@acm.org> <5563C9E9.1070700@redhat.com> <5564C2DD.2030700@acm.org> In-Reply-To: <5564C2DD.2030700@acm.org> On 05/26/15 15:00, Nathan Sidwell wrote: > On 05/25/15 21:18, Jason Merrill wrote: >> Hmm, are you seeing a case where TYPE_CANONICAL (to_type) has the may_alias >> attribute? > > Yes. This occurs when the newly created TRCAA pointer is to a self-canonical > type. The > else if (TYPE_CANONICAL (to_type) != to_type) > is false, so the newly created pointer is self-canonical too (and has TRCAA). > > If the canonical type should not have TRCAA we need to change the if condition to: > else if (TYPE_CANONICAL (to_type) != to_type || could_alias_all) > > where COULD_ALIAS_ALL is the incoming CAN_ALIAS_ALL value. Does that make sense? > > Making that change does stop the ICE I was seeing, but I've not done a full > test yet. Here's a patch implementing that change, When build_pointer_type_for_mode is passed true for CAN_ALIAS_ALL, we force creating a canonical type, continuing to pass false for that pointer's creation. booted & tested on x86-64-linux, ok? nathan 2015-05-25 Nathan Sidwell PR c++/66270 * tree.c (build_pointer_type_for_mode): Canonical type does not inherit can_alias_all. (build_reference_type_for_mode): Likewise. PR c++/66270 * g++.dg/ext/alias-canon3.C: New. Index: testsuite/g++.dg/ext/alias-canon3.C =================================================================== --- testsuite/g++.dg/ext/alias-canon3.C (revision 0) +++ testsuite/g++.dg/ext/alias-canon3.C (working copy) @@ -0,0 +1,12 @@ +// { dg-do compile } +// PR c++/66270 + +typedef float __m256 __attribute__ (( __vector_size__(32), __may_alias__ )); +struct A { + __m256 ymm; + const float &f() const; +}; + +const float &A::f() const { + return ymm[1]; +} Index: tree.c =================================================================== --- tree.c (revision 223636) +++ tree.c (working copy) @@ -7719,6 +7719,7 @@ build_pointer_type_for_mode (tree to_typ bool can_alias_all) { tree t; + bool could_alias = can_alias_all; if (to_type == error_mark_node) return error_mark_node; @@ -7756,7 +7757,7 @@ build_pointer_type_for_mode (tree to_typ if (TYPE_STRUCTURAL_EQUALITY_P (to_type)) SET_TYPE_STRUCTURAL_EQUALITY (t); - else if (TYPE_CANONICAL (to_type) != to_type) + else if (TYPE_CANONICAL (to_type) != to_type || could_alias) TYPE_CANONICAL (t) = build_pointer_type_for_mode (TYPE_CANONICAL (to_type), mode, false); @@ -7786,6 +7787,7 @@ build_reference_type_for_mode (tree to_t bool can_alias_all) { tree t; + bool could_alias = can_alias_all; if (to_type == error_mark_node) return error_mark_node; @@ -7823,7 +7825,7 @@ build_reference_type_for_mode (tree to_t if (TYPE_STRUCTURAL_EQUALITY_P (to_type)) SET_TYPE_STRUCTURAL_EQUALITY (t); - else if (TYPE_CANONICAL (to_type) != to_type) + else if (TYPE_CANONICAL (to_type) != to_type || could_alias) TYPE_CANONICAL (t) = build_reference_type_for_mode (TYPE_CANONICAL (to_type), mode, false);