From patchwork Fri Mar 9 02:30:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 10269561 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6085E6016D for ; Fri, 9 Mar 2018 02:30:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5137B29B98 for ; Fri, 9 Mar 2018 02:30:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5010A29C55; Fri, 9 Mar 2018 02:30:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E35EB29B98 for ; Fri, 9 Mar 2018 02:30:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750920AbeCICa1 (ORCPT ); Thu, 8 Mar 2018 21:30:27 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:36465 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750869AbeCICaZ (ORCPT ); Thu, 8 Mar 2018 21:30:25 -0500 Received: by mail-wm0-f67.google.com with SMTP id 188so1312846wme.1 for ; Thu, 08 Mar 2018 18:30:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=4jZiBS61zUiprHzgyp/bpPnafA+lDtoqB9iu/B5iIhE=; b=N27yYdEOe8rn6jKKyjlL4RS1Ys39kJY01YKA2JgQ88BG07/+KgbDywp1GxgPRarXh5 3CrbdAgaSLliUfhvCH+PnmqCi74cQ8mwYwHG6XfT2BivLR5zgdUZ/nnt9Q1IrZSr5hHm xUjspKYqktT4/gfv+dQPH4oFMgbAwW5Qn2MuNyUEoe3RTFwjTYZbjpsgQk11DmwM0LdR ASMCEp7zqZXjfjZZ6mGXX6ZCiqy59f7ZGE1Lt7Yyt8ajJnulMf51RXBrnfyRSK3siABy DaeUp4Ruoe38qAQkeftbDgPeOPvpSJ2MzWeklBOP7GDSQZfRDgb0ExEd4dGzDzDtqKrO GTcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=4jZiBS61zUiprHzgyp/bpPnafA+lDtoqB9iu/B5iIhE=; b=PmqquhhPyiX27RXE4XNU3ApDUuO+4NgwIg17cTT0up5J01KAYiiMhCzf+lv/PwrqhT dGtPeJVwKstOgOrcP4GidtXKy7zk+7sTDZ5N21QrSC4T8VeEK+gU59CAkl8lLNmCjV/r iKabwBOJ7PFrgWpKBkx3dhb1UXJw3ehAhSLWL+UXkic7zpmxnExuvLrtC0DvL5ZsESF2 kKviWJuBebtdPjXhXEiCIDdkbXN7hpyvLyHAodYnJ3dOQkpY1dNNXiVVp23XWRU9IkKS Fz+v2kIPgVcqWIQOyVTnjxV9TIz9wGZFNd/BdVhddXAqTAwh06ftxUfFlncyOmyCTgYX pVaw== X-Gm-Message-State: APf1xPD8QsbFDMcLYJpSpNXouB8gTtjUoGx6SW6VH6lfVf5S9ZF/8+ck 38nCA2wJMNaWJXM/R3Lz2BjLb65p X-Google-Smtp-Source: AG47ELs8YvgjOxsHt39nbw++3x1I/LNfRbsLCEETn838LagJYDc+A6M4I3AVio+ZSjPpl0YbCNYdXQ== X-Received: by 10.80.182.48 with SMTP id b45mr34764247ede.87.1520562624110; Thu, 08 Mar 2018 18:30:24 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:402a:9e00:b509:133b:1e4b:f083]) by smtp.gmail.com with ESMTPSA id y58sm163915edd.81.2018.03.08.18.30.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Mar 2018 18:30:23 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 4/5] symaddr: fold them into loads & stores Date: Fri, 9 Mar 2018 03:30:09 +0100 Message-Id: <20180309023010.94475-5-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180309023010.94475-1-luc.vanoostenryck@gmail.com> References: <20180309023010.94475-1-luc.vanoostenryck@gmail.com> Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Memory simplification can and effectively do a more precise job when more information is known about the memop's address. For example, it knows that two distinct symbol won't alias while, of course, nothing similar can be said if the address are mere pointers to some unknown objects. In other words, we prefer to see: load.32 %r2, 0[s] than: symaddr.32 %r1, s load.32 %r2, 0[%r1] So, to insure that memop use the symbol when possible, for each memop using the result of an OP_SYMADDR as address, replace the address by the symbol itself. Signed-off-by: Luc Van Oostenryck --- simplify.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/simplify.c b/simplify.c index a2edda479..b3cd76e3d 100644 --- a/simplify.c +++ b/simplify.c @@ -901,6 +901,16 @@ static int simplify_memop(struct instruction *insn) int one, ret = 0; pseudo_t orig = insn->src; + // try to fold symbol address into the access + if (orig->type == PSEUDO_REG) { + struct instruction *def = orig->def; + if (def->opcode == OP_SYMADDR) { + pseudo_t sym = def->symbol; + kill_use(&insn->src); + use_pseudo(insn, sym, &insn->src); + } + } + do { one = simplify_one_memop(insn, orig); ret |= one;