From patchwork Wed Jan 15 16:53:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 311198 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 438012C0091 for ; Thu, 16 Jan 2014 03:53:33 +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 :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=UuX46t+ofqKJ0cKuqhtm3/fgOMmZCHYUos4aHK3/c2U H/3v0ASsg9sKCy3iJfnIzmiULmrnhySZe7HloG54KSsNX1GkX5J3NwbY4a1EDIuE L2LpHdzXU/vtPKTcNEj6Z4afEHFok81SCjMNJ95fIIqE1dpieu7FtaN0KoDJOy8E = 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 :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=OekEOfw5FOzbq5L78MOpFsLbZ6g=; b=xM2P+hj/rpHyuH55Q qNiXGiLTBsqa8fylM02ou4QrFQxV+n7l2P/PO+1kti5comqmkDx4BhfNfBiQE1Vz Qo4Yeaz9FSPLUT1VbGGg1M2FhUk3gb/Yq7hzuALstL05fVuYV4rczuxmRXxMVltU 161eYStZJkNS3+RHhJB2LYPyyQ= Received: (qmail 25373 invoked by alias); 15 Jan 2014 16:53:26 -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 25364 invoked by uid 89); 15 Jan 2014 16:53:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 Jan 2014 16:53:24 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1W3TiR-0003tQ-Oo from Tom_deVries@mentor.com ; Wed, 15 Jan 2014 08:53:19 -0800 Received: from SVR-IES-FEM-01.mgc.mentorg.com ([137.202.0.104]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Wed, 15 Jan 2014 08:53:19 -0800 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.2.247.3; Wed, 15 Jan 2014 16:53:17 +0000 Message-ID: <52D6BCFC.6000408@mentor.com> Date: Wed, 15 Jan 2014 17:53:16 +0100 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: Eric Botcazou CC: GCC Patches , Richard Sandiford Subject: [PATCH] register CALL_INSN_FUNCTION_USAGE in find_all_hard_reg_sets Eric, This patch adds scanning of clobbers in CALL_INSN_FUNCTION_USAGE to find_all_hard_reg_sets. For MIPS, calls are split at some point. After the split, one of the resulting insns may clobber $6. But before the split, that's not explicit in the rtl representation of the unsplit call. For -fuse-caller-save, that's a problem, and Richard S. suggested to add the clobber of $6 to the CALL_INSN_FUNCTION_USAGE of the unsplit call. I wrote a patch for that ( http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00730.html ), but found that doing so did not fix the problem with -fuse-caller-save, because find_all_hard_reg_sets (the mechanism -fuse-caller-save uses to detect which registers are set or clobbered) does not take CALL_INSN_FUNCTION_USAGE into account. This patch fixes that. Build and reg-tested on MIPS. OK for stage1 if x86_64 bootstrap & reg-test succeeds? Thanks, - Tom 2014-01-15 Tom de Vries * rtlanal.c (find_all_hard_reg_sets): Note INSN_CALL_FUNCTION_USAGE clobbers. diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index 7e27774..64f83ac 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -1034,8 +1034,25 @@ find_all_hard_reg_sets (const_rtx insn, HARD_REG_SET *pset, bool implicit) CLEAR_HARD_REG_SET (*pset); note_stores (PATTERN (insn), record_hard_reg_sets, pset); - if (implicit && CALL_P (insn)) - IOR_HARD_REG_SET (*pset, call_used_reg_set); + if (CALL_P (insn)) + { + if (implicit) + IOR_HARD_REG_SET (*pset, call_used_reg_set); + + for (link = CALL_INSN_FUNCTION_USAGE (insn); link; link = XEXP (link, 1)) + { + rtx op, reg; + + if (GET_CODE (op = XEXP (link, 0)) == CLOBBER + && REG_P (reg = XEXP (op, 0))) + { + unsigned int i; + + for (i = REGNO (reg) ; i < END_HARD_REGNO (reg); i++) + SET_HARD_REG_BIT (*pset, i); + } + } + } for (link = REG_NOTES (insn); link; link = XEXP (link, 1)) if (REG_NOTE_KIND (link) == REG_INC) record_hard_reg_sets (XEXP (link, 0), NULL, pset);