From patchwork Mon Apr 9 17:43:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 133049 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp482471ljb; Mon, 9 Apr 2018 10:43:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx48vvHrObFt+Zh67Yo5uDI/477y5Q4ub3bzQDs5u93wTnCDQ6PKmVK0ZiVugMX4kHbCVbn1Q X-Received: by 10.101.67.76 with SMTP id k12mr8272178pgq.39.1523295818743; Mon, 09 Apr 2018 10:43:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523295818; cv=none; d=google.com; s=arc-20160816; b=MtoXd7rgumOMzMCzhjRGk+t3wlSseFw3kSHhVpJOB3javWAlzjGiiPL3tzyJU5Ba4C pWBwb23k/l+W6IOBju5gmEjRGD7HeoZEyQvkjuAyHCRMLTmSVCiew23NRNOqCrNbg/dj mEYsiDTu1ad3eojh/k+iWMZZ5DKMc11OSDp5PyQxoaszrqOGnuLHVVnG+C9Ra6nn1Xkx XluhFLnz6ZATw5ZxNRY0Z91ROVa/sLXSX6QGkMTfZUsuuns9yxyxXSXJ7fF0G/tQUsVj hTV+VuTVqj5kRFOGem30u26pZC4whXqxr9YqcRRNzWv9zKy3Bn+VEOnoZX0YNdhWn7j5 EGkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date:subject:cc:mail-followup-to :to:from:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=fjjG8Ykx0i+zeHYLtt2rD+kmF+JRLzSEDknUrMZjegY=; b=C3j5BwgQsPDuJ/NAsJOvprUi8UkXJAweAh51HWndIspsw79Ebec2jW0WVMxHpGZrp5 xd4hfSW2TixpFspDyTEwdvdE2dwuF0XmkZB6ClYnZ8H8F4DRTFS6ubW5y9GLqGUVRdjS uDPuCo2xWJOAAoP/Jvwup++8cMYtBVYwYoqsrusrcuUkV/8akrM25dxYWnkCxikKWH0J 5QA3VHAtJdJZIESC4lSHuSRDYR/6vebqO7Ys3fmcggUEWxpBAwqsZ3yD4qwRMxFVpO6x u1/7tbgTmhcWT+ipLsxx+w50TRKPQZLHQFFYgJWD0fgtfD9zQbA9M+o+EuIYCgECinm9 LbAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hbiM/3bp; spf=pass (google.com: domain of gcc-patches-return-476071-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-476071-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id j4-v6si749476pll.128.2018.04.09.10.43.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Apr 2018 10:43:38 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-476071-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hbiM/3bp; spf=pass (google.com: domain of gcc-patches-return-476071-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-476071-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=YRSAJqxT4Z0hgcP5hB+XijzKR8TRZ43WpK2In2lbprtVayxP4V ikb7y3L8fUIDTaKIfjKRJyfR1AaEUi+MvXG/RLd5AFfVHxij4eAEN4vgb7LkaZqA a+i+rxmy9+pceKAvH9luK582qdAID+J051l1bxad3qCgKzuioBJ+v2zE8= 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:subject:date:message-id:mime-version:content-type; s= default; bh=YZnAYQOWsUPo7YWmeo4AT3CVXC4=; b=hbiM/3bpj7bZejPf9Rwi hcgJ70ioACWBX2wraDkvGbvnDa5yFs5WLCs1sb31omvN2+vWEJLjsOGcloM9ziVC 8+SiGDd12kAB5DTkbuBOTPRksmXWIrmHFSecisP4F32sBnatGQrE9rDTy5ZxSbEe X2N9c8a2ZPsG2OkAFZNahho= Received: (qmail 127016 invoked by alias); 9 Apr 2018 17:43:25 -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 126992 invoked by uid 89); 9 Apr 2018 17:43:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f173.google.com Received: from mail-wr0-f173.google.com (HELO mail-wr0-f173.google.com) (209.85.128.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Apr 2018 17:43:23 +0000 Received: by mail-wr0-f173.google.com with SMTP id c24so10406298wrc.6 for ; Mon, 09 Apr 2018 10:43:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:cc:subject:date :message-id:user-agent:mime-version; bh=fjjG8Ykx0i+zeHYLtt2rD+kmF+JRLzSEDknUrMZjegY=; b=m1fL6aokb/Xmfx5rFTaa18H3Kzl7chbW0rhy3i91CcBMm11P58qFgoUVh7uXg61tlG yEHPxk+vNbGlI1lMHZGmG/qqYm+7cnnH0V90l123l2m6ffWIPBlAqimj8F1raF/9Oc4s 2SWaZptPm0c6MjEJSXuPB4DqBmnMNVPHBiCLqSXVTq7GwwnQYDLQC0gZbh0dU42e76am trYxYmRgVhg3AAjH6kRcKDlLsoI2H6CbUt8aH5tf6VRAmxL4nPIuaIs3qE6Ii/gp78hG bz91UBGg0qi0CnBjG9aHLUIXcs6Kv9qZGAG5vS6acVpbuwuJKxMHj/e02QrCNaRVmbeP PwtA== X-Gm-Message-State: AElRT7GI7g/Ka4ZW+stMZ8iEPyYc/SVpRD5FwlV7yRA58GYFhqThWPMp JdcSG3Pbq+m4t5Y6/5wpz9myWA== X-Received: by 10.223.133.6 with SMTP id 6mr28161433wrh.53.1523295801371; Mon, 09 Apr 2018 10:43:21 -0700 (PDT) Received: from localhost (116.58.7.51.dyn.plus.net. [51.7.58.116]) by smtp.gmail.com with ESMTPSA id b203sm1414273wmh.2.2018.04.09.10.43.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Apr 2018 10:43:20 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, sameera.deshpande@linaro.org, richard.sandiford@linaro.org Cc: sameera.deshpande@linaro.org Subject: Set insn_last_address in final_1 Date: Mon, 09 Apr 2018 18:43:20 +0100 Message-ID: <87bmes6zt3.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 final_1 already sets insn_current_address for each instruction, making it possible to use some of the address functions in final.c during assembly generation. This patch also sets insn_last_address, since as the comment says, we can treat final as a shorten_branches pass that does nothing. It's then possible to use insn_current_reference_address during final as well. This is needed for the aarch64.md definitions of far_branch to work: (set (attr "far_branch") (if_then_else (and (ge (minus (match_dup 2) (pc)) (const_int -1048576)) (lt (minus (match_dup 2) (pc)) (const_int 1048572))) (const_int 0) (const_int 1)))] This value (tested only during final) uses the difference between the INSN_ADDRESSES of operand 2 and insn_current_reference_address to calculate a conservatively-correct estimate of the branch distance. It takes into account the worst-case gap due to alignment, whereas a direct comparison of INSN_ADDRESSES would give an unreliable, optimistic result. Tested on aarch64-linux-gnu and x86_64-linux-gnu. Sameera confirms that it fixes the original bug, but there's no sharable testcase. OK to install? Richard 2018-04-09 Richard Sandiford gcc/ * final.c (final_1): Set insn_last_address as well as insn_current_address. Index: gcc/final.c =================================================================== --- gcc/final.c 2018-04-09 18:40:26.887628387 +0100 +++ gcc/final.c 2018-04-09 18:40:27.033624471 +0100 @@ -2081,6 +2081,9 @@ final_1 (rtx_insn *first, FILE *file, in } else insn_current_address = INSN_ADDRESSES (INSN_UID (insn)); + /* final can be seen as an iteration of shorten_branches that + does nothing (since a fixed point has already been reached). */ + insn_last_address = insn_current_address; } dump_basic_block_info (file, insn, start_to_bb, end_to_bb,