From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4242 invoked by alias); 28 Nov 2014 16:22:43 -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 4233 invoked by uid 89); 28 Nov 2014 16:22:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 28 Nov 2014 16:22:42 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 081AC2B9035A for ; Fri, 28 Nov 2014 17:22:39 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id p6VL4bqCy4Nf for ; Fri, 28 Nov 2014 17:22:38 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id D69982B90336 for ; Fri, 28 Nov 2014 17:22:38 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Fix ICE on unaligned record field Date: Fri, 28 Nov 2014 17:09:00 -0000 Message-ID: <3887233.jQSJCmu5YU@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.29-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart1476159.cy3Nmh0aru" Content-Transfer-Encoding: 7Bit X-SW-Source: 2014-11/txt/msg03508.txt.bz2 --nextPart1476159.cy3Nmh0aru Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Content-length: 773 Hi, the attached Ada testcase triggers an assertion in the RTL expander for the address operator because the operator has been applied to a non-byte-aligned record field. The problematic ADDR_EXPR is built by ipa_modify_call_arguments which has a hole when get_addr_base_and_unit_offset returns NULL_TREE: the variable offset case is handled but not the non-byte-aligned case, which can rountinely happen in Ada, hence the proposed fix. Tested on x86_64-suse-linux, OK for the mainline? 2014-11-28 Eric Botcazou * ipa-prop.c (ipa_modify_call_arguments): Properly deal with unaligned aggregate parameters passed by value. 2014-11-28 Eric Botcazou * gnat.dg/specs/pack12.ads: New test. -- Eric Botcazou --nextPart1476159.cy3Nmh0aru Content-Disposition: attachment; filename="p.diff" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="p.diff" Content-length: 1767 Index: ipa-prop.c =================================================================== --- ipa-prop.c (revision 218133) +++ ipa-prop.c (working copy) @@ -3939,6 +3939,39 @@ ipa_modify_call_arguments (struct cgraph /* Aggregate arguments can have non-invariant addresses. */ if (!base) { + /* ??? If the original aggregate is passed by value, it may + be not aligned on a unit boundary, in which case taking + directly its address below is forbidden. Unfortunately + get_addr_base_and_unit_offset doesn't differentiate its + two failure modes so we need to get our hands dirty. */ + if (!addrof) + { + tree offset; + HOST_WIDE_INT bitsize, bitpos; + machine_mode mode; + int unsignedp, volatilep = 0; + get_inner_reference (prev_base, &bitsize, &bitpos, + &offset, &mode, &unsignedp, + &volatilep, false); + if (bitpos % BITS_PER_UNIT) + { + tree tmp + = create_tmp_reg (TREE_TYPE (prev_base), NULL); + tree *argp + = gimple_call_arg_ptr (stmt, adj->base_index); + gimple tem = gimple_build_assign (tmp, prev_base); + tree vuse = gimple_vuse (stmt); + tree new_vdef = copy_ssa_name (vuse, tem); + gimple_set_vuse (tem, vuse); + gimple_set_vdef (tem, new_vdef); + SET_USE (gimple_vuse_op (stmt), new_vdef); + /* Insert the temporary ahead of every subsequent + adjustment and replace the argument in the call + in case it is referenced more than once. */ + gsi_insert_after (&prev_gsi, tem, GSI_SAME_STMT); + *argp = prev_base = tmp; + } + } base = build_fold_addr_expr (prev_base); off = build_int_cst (adj->alias_ptr_type, adj->offset / BITS_PER_UNIT); --nextPart1476159.cy3Nmh0aru Content-Disposition: attachment; filename="pack12.ads" Content-Transfer-Encoding: 7Bit Content-Type: text/x-adasrc; charset="UTF-8"; name="pack12.ads" Content-length: 296 -- { dg-do compile } -- { dg-options "-O2" } package Pack12 is type Rec1 is record B : Boolean; N : Natural; end record; type Rec2 is record B : Boolean; R : Rec1; end record; pragma Pack (Rec2); type Rec3 is tagged record R : Rec2; end record; end Pack12; --nextPart1476159.cy3Nmh0aru--