From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 60957 invoked by alias); 14 Mar 2015 13:02:49 -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 60948 invoked by uid 89); 14 Mar 2015 13:02:48 -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_00,FREEMAIL_FROM,KAM_FROM_URIBL_PCCC,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-pd0-f177.google.com Received: from mail-pd0-f177.google.com (HELO mail-pd0-f177.google.com) (209.85.192.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Sat, 14 Mar 2015 13:02:47 +0000 Received: by pdbcz9 with SMTP id cz9so11957713pdb.3 for ; Sat, 14 Mar 2015 06:02:45 -0700 (PDT) X-Received: by 10.66.221.194 with SMTP id qg2mr114727826pac.106.1426338165247; Sat, 14 Mar 2015 06:02:45 -0700 (PDT) Received: from bubble.grove.modra.org ([58.160.155.134]) by mx.google.com with ESMTPSA id z1sm8230821pdp.52.2015.03.14.06.02.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Mar 2015 06:02:44 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id CA1AAEA0139; Sat, 14 Mar 2015 23:32:38 +1030 (ACDT) Date: Sat, 14 Mar 2015 13:02:00 -0000 From: Alan Modra To: gcc-patches@gcc.gnu.org Subject: Fix for PRs 36043, 58744 and 65408 Message-ID: <20150314130238.GD16488@bubble.grove.modra.org> Mail-Followup-To: gcc-patches@gcc.gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-03/txt/msg00774.txt.bz2 This is Richi's prototype patch in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36043#c23 with fixes for blocks larger than one reg, big-endian, and BLOCK_REG_PADDING. I also removed the operand_subword_force since we may as well let narrow_bit_field_mem in extract_bit_field do that for us. It is necessary to do the BLOCK_REG_PADDING shift after we've loaded the block or else repeat the bit-field extraction in that case. Bootstrapped and regression tested (-m32 and -m64) x86_64-linux and powerpc64-linux. OK to apply? I'll also throw together a testcase or three. For execute tests I'm thinking of using sbrk to locate an odd sized struct such that access past the end segfaults, rather than mmap/munmap as was done in the pr36043 testcase. Does that sound reasonable? PR target/65408 PR target/58744 PR middle-end/36043 * calls.c (load_register_parameters): Don't load past end of mem unless suitably aligned. Index: gcc/calls.c =================================================================== --- gcc/calls.c (revision 221435) +++ gcc/calls.c (working copy) @@ -2090,6 +2090,26 @@ load_register_parameters (struct arg_data *args, i (XEXP (args[i].value, 0), size))) *sibcall_failure = 1; + if (size % UNITS_PER_WORD == 0 + || MEM_ALIGN (mem) % BITS_PER_WORD == 0) + move_block_to_reg (REGNO (reg), mem, nregs, args[i].mode); + else + { + if (nregs > 1) + move_block_to_reg (REGNO (reg), mem, nregs - 1, + args[i].mode); + rtx dest = gen_rtx_REG (word_mode, REGNO (reg) + nregs - 1); + unsigned int bitoff = (nregs - 1) * BITS_PER_WORD; + unsigned int bitsize = size * BITS_PER_UNIT - bitoff; + rtx x = extract_bit_field (mem, bitsize, bitoff, 1, + dest, word_mode, word_mode); + if (BYTES_BIG_ENDIAN) + x = expand_shift (LSHIFT_EXPR, word_mode, x, + BITS_PER_WORD - bitsize, dest, 1); + if (x != dest) + emit_move_insn (dest, x); + } + /* Handle a BLKmode that needs shifting. */ if (nregs == 1 && size < UNITS_PER_WORD #ifdef BLOCK_REG_PADDING @@ -2097,22 +2117,18 @@ load_register_parameters (struct arg_data *args, i #else && BYTES_BIG_ENDIAN #endif - ) + ) { - rtx tem = operand_subword_force (mem, 0, args[i].mode); - rtx ri = gen_rtx_REG (word_mode, REGNO (reg)); - rtx x = gen_reg_rtx (word_mode); + rtx dest = gen_rtx_REG (word_mode, REGNO (reg)); int shift = (UNITS_PER_WORD - size) * BITS_PER_UNIT; - enum tree_code dir = BYTES_BIG_ENDIAN ? RSHIFT_EXPR - : LSHIFT_EXPR; + enum tree_code dir = (BYTES_BIG_ENDIAN + ? RSHIFT_EXPR : LSHIFT_EXPR); + rtx x; - emit_move_insn (x, tem); - x = expand_shift (dir, word_mode, x, shift, ri, 1); - if (x != ri) - emit_move_insn (ri, x); + x = expand_shift (dir, word_mode, dest, shift, dest, 1); + if (x != dest) + emit_move_insn (dest, x); } - else - move_block_to_reg (REGNO (reg), mem, nregs, args[i].mode); } /* When a parameter is a block, and perhaps in other cases, it is -- Alan Modra Australia Development Lab, IBM