From patchwork Sun May 22 21:13:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 96782 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]) by ozlabs.org (Postfix) with SMTP id 7F2A5B6FA6 for ; Mon, 23 May 2011 07:13:59 +1000 (EST) Received: (qmail 26918 invoked by alias); 22 May 2011 21:13:57 -0000 Received: (qmail 26909 invoked by uid 22791); 22 May 2011 21:13:56 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RFC_ABUSE_POST, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-wy0-f175.google.com (HELO mail-wy0-f175.google.com) (74.125.82.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 22 May 2011 21:13:42 +0000 Received: by wye20 with SMTP id 20so4604862wye.20 for ; Sun, 22 May 2011 14:13:41 -0700 (PDT) Received: by 10.227.205.12 with SMTP id fo12mr1564650wbb.70.1306098821686; Sun, 22 May 2011 14:13:41 -0700 (PDT) Received: from localhost (rsandifo.gotadsl.co.uk [82.133.89.107]) by mx.google.com with ESMTPS id k2sm3676326wby.0.2011.05.22.14.13.39 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 22 May 2011 14:13:40 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Subject: PR 48826: NOTE_INSN_CALL_ARG_LOCATION vs. define_split Date: Sun, 22 May 2011 22:13:34 +0100 Message-ID: <87tycm4ewx.fsf@firetop.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 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 In PR 44826, we split a pre-reload call into another call followed by a load of GP. The problem is that we're running the split pass after var-tracking, and the original call had a NOTE_INSN_CALL_ARG_LOCATION attached to it. We need to move the note to the new call, just like we already move other properties of the call. This shows up on 32-bit MIPS GNU/Linux at -O -g, because the first post-epilogue scheduling pass is after var tracking. It doesn't show up on -O2 and above because an earlier pass does the split. I think the bug could in principle trigger on other targets with call-clobbered GPs (e.g. some variants of Alpha, ia64 and PA). However, most other ports split on reload_completed, whereas MIPS does it on epilogue_completed, so perhaps it really is only MIPS. Tested on mips-linux-gnu and x86_64-linux-gnu. OK to install? Richard gcc/ PR rtl-optimization/48826 * emit-rtl.c (try_split): When splitting a call that is followed by a NOTE_INSN_CALL_ARG_LOCATION, move the note after the new call. Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c 2011-05-22 17:13:06.000000000 +0100 +++ gcc/emit-rtl.c 2011-05-22 20:37:09.000000000 +0100 @@ -3476,11 +3476,27 @@ try_split (rtx pat, rtx trial, int last) for (insn = insn_last; insn ; insn = PREV_INSN (insn)) if (CALL_P (insn)) { + rtx next; rtx *p = &CALL_INSN_FUNCTION_USAGE (insn); while (*p) p = &XEXP (*p, 1); *p = CALL_INSN_FUNCTION_USAGE (trial); SIBLING_CALL_P (insn) = SIBLING_CALL_P (trial); + /* If the new call is the last instruction in the sequence, + it will effectively replace the old call in-situ. Otherwise + we must move any following NOTE_INSN_CALL_ARG_LOCATION note + so that it comes immediately after the new call. */ + if (NEXT_INSN (insn)) + { + next = NEXT_INSN (trial); + if (next + && NOTE_P (next) + && NOTE_KIND (next) == NOTE_INSN_CALL_ARG_LOCATION) + { + remove_insn (next); + add_insn_after (next, insn, NULL); + } + } } }