From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7334 invoked by alias); 2 May 2003 13:46:02 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 7293 invoked by uid 71); 2 May 2003 13:46:01 -0000 Date: Fri, 02 May 2003 13:46:00 -0000 Message-ID: <20030502134601.7287.qmail@sources.redhat.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, From: Richard Earnshaw Subject: Re: optimization/10592: [arm] caller-save incorrectly handles a reloaded SET_DEST operand Reply-To: Richard Earnshaw X-SW-Source: 2003-05/txt/msg00131.txt.bz2 List-Id: The following reply was made to PR optimization/10592; it has been noted by GNATS. From: Richard Earnshaw To: gcc-bugs@gcc.gnu.org, gcc-gnats@gcc.gnu.org, nobody@gcc.gnu.org, ryan.pipkin@inet.com, law@redhat.com Cc: Richard.Earnshaw@arm.com Subject: Re: optimization/10592: [arm] caller-save incorrectly handles a reloaded SET_DEST operand Date: Fri, 02 May 2003 14:45:33 +0100 [Jeff, I've put you on CC because you appear to be the original author of the relevant code (back in Oct 98).] Some more detailed analysis... The problem we have here comes from the use of caller-save register allocation and the failure to allocate a register to a pseudo that is equivalent to a memory location that is derived from a caller-saved register value. Specifically, we have the sequence prior to reload of (call_insn:HI 249 227 326 2 0x4067c5d8 (parallel [ (set (reg:SI 0 r0) (call (mem:SI (symbol_ref:SI ("strncpy") ) [0 S4 A32]) (const_int 0 [0x0]))) (use (const_int 0 [0x0])) (clobber (reg:SI 14 lr)) ]) 190 {*call_value_symbol} (insn_list:REG_DEP_ANTI 76 (insn_list 248 (insn_list 247 (insn_list 246 (insn_list:REG_DEP_ANTI 30 (insn_list:REG_DEP_ANTI 172 (insn_list 210 (insn_list:REG_DEP_ANTI 75 (insn_list:REG_DEP_ANTI 74 (insn_list 47 (insn_list 227 (nil)))))))))))) (expr_list:REG_DEAD (reg:SI 1 r1 [ pName ]) (expr_list:REG_DEAD (reg:SI 2 r2) (expr_list:REG_UNUSED (reg:SI 0 r0) (expr_list:REG_UNUSED (reg:SI 14 lr) (expr_list:REG_EH_REGION (const_int 0 [0x0]) (nil)))))) (expr_list (use (reg:SI 2 r2)) (expr_list (use (reg:SI 1 r1 [ pName ])) (expr_list (use (reg:SI 0 r0)) (nil))))) (insn:HI 326 249 331 2 0x40658dc0 (set (reg:SI 98) (plus:SI (reg/v:SI 49 [ base ]) (const_int 156 [0x9c]))) 4 {*arm_addsi3} (insn_list 4 (insn_list:REG_DEP_ANTI 249 (nil))) (expr_list:REG_EQUIV (mem/s:SI (plus:SI (reg/v/u/f:SI 48 [ this ]) (const_int 540 [0x21c])) [39 .pValue3+0 S4 A32]) (nil))) Note that pseudo 98 has a REG_EQUIV of mem(plus (r48, 540)) Now global-alloc assigns r48 to the call-clobbered register r12, but spills r98 back into its reg_equiv location. When save_call_clobbered_res runs, therefore, r12 is stored to the stack before the call insn, but when scanning r326 mark_referenced_regs ignores the SET_DEST in insn 326 because it is a REG: if (code == SET || code == CLOBBER) { x = SET_DEST (x); code = GET_CODE (x); if (code == REG || code == PC || code == CC0 || (code == SUBREG && GET_CODE (SUBREG_REG (x)) == REG /* If we're setting only part of a multi-word register, we shall mark it as referenced, because the words that are not being set should be restored. */ && ((GET_MODE_SIZE (GET_MODE (x)) >= GET_MODE_SIZE (GET_MODE (SUBREG_REG (x)))) || (GET_MODE_SIZE (GET_MODE (SUBREG_REG (x))) <= UNITS_PER_WORD)))) return; We thus end up with the sequence of instructions str ip, [frame+xxx] call strncpy add tmp, r9, #156 str tmp, [ip+540] // ip not restored first I think the fix may be to make mark_referenced_regs only return if REG is a hard register (similarly for SUBREG). Jeff, any thoughts? R.