From patchwork Fri Mar 29 13:06:06 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 232397 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 433242C00AA for ; Sat, 30 Mar 2013 00:08:01 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:in-reply-to:subject:mime-version:content-type:message-id :date; q=dns; s=default; b=iTIqJ/iOH9wnoOyhRXBRnk9ONSq9u14yjuwzC By4RaAd1vGbIFF2Kk46QFwQvmDJprlQEIoskC/LOrno5FvwClM1qI1G3jrdglc53 ifP4UwNIciGj9vkttag72KVBqFYCN0hfr4OKd0VWIPfC7SlJ9WjMVQL2VN8zXFo+ BTk4jU= 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:from :to:cc:in-reply-to:subject:mime-version:content-type:message-id :date; s=default; bh=FSRiXTFok5tWpnffcC4kkG4iinE=; b=k5tjuAR4SzG bWKCdEpGRMEChOyIEdBGihDUA6aIG77DmqmEYNU4c4424SVnu0KHaXm3g3j2+r44 mlO9GU9bAzk8FVPXDfWWK659OuSrbNwS3XA8tWg7D6b40EGRgYGDNTQyMzxqL9QC jTupcfC5pN24G3iQIp46qzwtIqhatxSo= Received: (qmail 23878 invoked by alias); 29 Mar 2013 13:06:24 -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 23526 invoked by uid 89); 29 Mar 2013 13:06:17 -0000 X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, KAM_STOCKTIP, KHOP_RCVD_UNTRUST, KHOP_THREADED, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL autolearn=no version=3.3.1 Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Fri, 29 Mar 2013 13:06:08 +0000 Received: from svr-orw-fem-01.mgc.mentorg.com ([147.34.98.93]) by relay1.mentorg.com with esmtp id 1ULZ0R-0000GD-0q from Tom_deVries@mentor.com ; Fri, 29 Mar 2013 06:06:07 -0700 Received: from SVR-ORW-FEM-03.mgc.mentorg.com ([147.34.97.39]) by svr-orw-fem-01.mgc.mentorg.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 29 Mar 2013 06:06:06 -0700 Received: from build1-lucid-cs (147.34.91.1) by svr-orw-fem-03.mgc.mentorg.com (147.34.97.39) with Microsoft SMTP Server id 14.1.289.1; Fri, 29 Mar 2013 06:06:06 -0700 Received: by build1-lucid-cs (Postfix, from userid 49877) id 205BF4213AB; Fri, 29 Mar 2013 06:06:05 -0700 (PDT) From: Tom de Vries To: Vladimir Makarov CC: gcc-patches In-Reply-To: <51558EF4.1030106@mentor.com> Subject: [PATCH][02/10] -fuse-caller-save - Add new reg-note REG_CALL_DECL MIME-Version: 1.0 Message-ID: <20130329130606.205BF4213AB@build1-lucid-cs> Date: Fri, 29 Mar 2013 06:06:06 -0700 X-Virus-Found: No Vladimir, This patch addes the REG_CALL_DECL reg-note. Using the reg-note we are able to easily link call_insns to their corresponding declaration, even after the calls may have been split into an insn (set register to function address) and a call_insn (call register), which can happen for f.i. sh, and mips with -mabi-calls. Thanks, -Tom 2013-03-29 Radovan Obradovic Tom de Vries * reg-notes.def (REG_NOTE (CALL_DECL)): New reg-note REG_CALL_DECL. * calls.c (expand_call, emit_library_call_value_1): Add REG_CALL_DECL reg-note. * combine.c (distribute_notes): Handle REG_CALL_DECL reg-note. * emit-rtl.c (try_split): Same. diff --git a/gcc/calls.c b/gcc/calls.c index cdab8e0..39571da 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -3158,6 +3158,19 @@ expand_call (tree exp, rtx target, int ignore) next_arg_reg, valreg, old_inhibit_defer_pop, call_fusage, flags, args_so_far); + if (flag_use_caller_save) + { + rtx last, datum = NULL_RTX; + if (fndecl != NULL_TREE) + { + datum = XEXP (DECL_RTL (fndecl), 0); + gcc_assert (datum != NULL_RTX + && GET_CODE (datum) == SYMBOL_REF); + } + last = last_call_insn (); + add_reg_note (last, REG_CALL_DECL, datum); + } + /* If the call setup or the call itself overlaps with anything of the argument setup we probably clobbered our call address. In that case we can't do sibcalls. */ @@ -4185,6 +4198,14 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value, valreg, old_inhibit_defer_pop + 1, call_fusage, flags, args_so_far); + if (flag_use_caller_save) + { + rtx last, datum = orgfun; + gcc_assert (GET_CODE (datum) == SYMBOL_REF); + last = last_call_insn (); + add_reg_note (last, REG_CALL_DECL, datum); + } + /* Right-shift returned value if necessary. */ if (!pcc_struct_value && TYPE_MODE (tfom) != BLKmode diff --git a/gcc/combine.c b/gcc/combine.c index acb4cb4..191eb71 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -13187,6 +13187,7 @@ distribute_notes (rtx notes, rtx from_insn, rtx i3, rtx i2, rtx elim_i2, case REG_NORETURN: case REG_SETJMP: case REG_TM: + case REG_CALL_DECL: /* These notes must remain with the call. It should not be possible for both I2 and I3 to be a call. */ if (CALL_P (i3)) diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index e412bef..e4843fe 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -3473,6 +3473,7 @@ try_split (rtx pat, rtx trial, int last) int probability; rtx insn_last, insn; int njumps = 0; + rtx call_insn = NULL_RTX; /* We're not good at redistributing frame information. */ if (RTX_FRAME_RELATED_P (trial)) @@ -3545,6 +3546,9 @@ try_split (rtx pat, rtx trial, int last) { rtx next, *p; + gcc_assert (call_insn == NULL_RTX); + call_insn = insn; + /* Add the old CALL_INSN_FUNCTION_USAGE to whatever the target may have explicitly specified. */ p = &CALL_INSN_FUNCTION_USAGE (insn); @@ -3616,6 +3620,11 @@ try_split (rtx pat, rtx trial, int last) fixup_args_size_notes (NULL_RTX, insn_last, INTVAL (XEXP (note, 0))); break; + case REG_CALL_DECL: + gcc_assert (call_insn != NULL_RTX); + add_reg_note (call_insn, REG_NOTE_KIND (note), XEXP (note, 0)); + break; + default: break; } diff --git a/gcc/reg-notes.def b/gcc/reg-notes.def index db61c09..f0b6dad 100644 --- a/gcc/reg-notes.def +++ b/gcc/reg-notes.def @@ -216,3 +216,8 @@ REG_NOTE (ARGS_SIZE) that the return value of a call can be used to reinitialize a pseudo reg. */ REG_NOTE (RETURNED) + +/* Used to mark a call with the function decl called by the call. + The decl might not be available in the call due to splitting of the call + insn. This note is a SYMBOL_REF. */ +REG_NOTE (CALL_DECL)