From patchwork Sun Nov 20 01:10:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tsukasa OI X-Patchwork-Id: 23363 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp928214wrr; Sat, 19 Nov 2022 17:11:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf4zUtSyfw4CIkoizfDn2l/7gqEreokw6ItAfq0tE87YliRBR/ZD25X8FLSrQ/G7M79Vh15m X-Received: by 2002:a17:906:82d1:b0:7ae:63e3:bfc4 with SMTP id a17-20020a17090682d100b007ae63e3bfc4mr2553796ejy.348.1668906661869; Sat, 19 Nov 2022 17:11:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668906661; cv=none; d=google.com; s=arc-20160816; b=gFucXXKuQLJDOWukypMAeK0+q2WROB6wgRKCdMI4SzsBSTbMLM9vlvVzUq52NEbzai wYcnGNRG1xPOT9Xuo1B/ld02bSE34x6LU+ZbfeA1aBsRQqdttlXQF0xpgymqrKQUrsN1 OFIs26eUXhY5cL9kZBgfVeduu6rD/EMZviV8UOQeX2bQXvUbY0emGDNP7KYaftQVTEau k5PqW97M29zBdAufoZ2rToefcIeSgxYLNV3CxKlICcKKRrAWyxPZDhrSSlij4dFCJfwl j2gvGvwj+7De8xASWimMNNk4CX0y4QKSwwC5pzmx9pZ0q/x9Wg18HZ6PIWs/BC7oLbUz t1zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=b8rnXkxMJlHqqQ+XwmjUi9OsXY0Ji4YhRBWKPbh3SZQ=; b=Tg68/N8eipNmfB7Yq2MrjlF4k0agfG1RmZQQT22hyuBuIWY4mLwYCJDaR/i09Rt9Hk H1+APqx0h36rgp8JapumqzCGS/g18ZQueBvn5AEmIch/sauy/n8QaYvnHkaDwbW26kuQ Qr8snuBp/qCBLKswWxyi2WM3sMeCk++R49cn2hhhLLiyAKKMnoDdHOB5ffa5lYdDFa3Q Njsz3pFDOhNHRRogxIdij5j3kA6LppDObWWTSjIeDzvx2sUMQddqSdxFXSqkIC0kJUPC daRQ/5v/bOm9E8JKm2+wUS3R202XSk3Spl+2T4hPwdwW7v8jzjxkbSGgK3jVxQs3fJbC noJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=H09IfaPL; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id v6-20020a056402348600b004661ece3fabsi6807517edc.575.2022.11.19.17.11.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Nov 2022 17:11:01 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=H09IfaPL; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 15D7C3895FCE for ; Sun, 20 Nov 2022 01:10:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 15D7C3895FCE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668906649; bh=b8rnXkxMJlHqqQ+XwmjUi9OsXY0Ji4YhRBWKPbh3SZQ=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=H09IfaPLI7ZObjugz/u876ZZO821PWxepbBacVFYNRVGwVpu2TY/hEioWUepbR4mh E2rPQzk5bpdg5dwhPcPQOFeIrlQBpFAiF/6LEQQHBsRqfMhql9c241T2vlqkWAVggr rMRD9b9G9eWxQkEXIXSPA4S0YSQuXb8q91m1fdNA= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-sender-0.a4lg.com (mail-sender.a4lg.com [153.120.152.154]) by sourceware.org (Postfix) with ESMTPS id 81C44388B693 for ; Sun, 20 Nov 2022 01:10:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 81C44388B693 Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 49D0D300089; Sun, 20 Nov 2022 01:10:21 +0000 (UTC) To: Tsukasa OI , Nelson Chu , Kito Cheng , Palmer Dabbelt Cc: binutils@sourceware.org Subject: [PATCH 1/3] RISC-V: Easy optimization on riscv_search_mapping_symbol Date: Sun, 20 Nov 2022 01:10:07 +0000 Message-Id: <88793c204c9270376959c6276fb1b63275bef3c8.1668906599.git.research_trasio@irq.a4lg.com> In-Reply-To: References: Mime-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Tsukasa OI via Binutils From: Tsukasa OI Reply-To: Tsukasa OI Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749975471592077723?= X-GMAIL-MSGID: =?utf-8?q?1749975471592077723?= From: Tsukasa OI Before further optimization, we can optimize the function riscv_search_mapping_symbol a bit for clarity. opcodes/ChangeLog: * riscv-dis.c (riscv_search_mapping_symbol): Make MAP_INSN default considering major usecases. Remove setting found here as no one uses the value after setting this. memaddr cannot be negative so simplify and change comment. Idea-by: Nelson Chu --- opcodes/riscv-dis.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c index 32e7b1174436..9ea4da9b219b 100644 --- a/opcodes/riscv-dis.c +++ b/opcodes/riscv-dis.c @@ -1132,18 +1132,16 @@ riscv_search_mapping_symbol (bfd_vma memaddr, /* Decide whether to print the data or instruction by default, in case we can not find the corresponding mapping symbols. */ - mstate = MAP_DATA; - if ((info->section - && info->section->flags & SEC_CODE) - || !info->section) - mstate = MAP_INSN; + mstate = MAP_INSN; + if (info->section && (info->section->flags & SEC_CODE) == 0) + mstate = MAP_DATA; if (info->symtab_size == 0 || bfd_asymbol_flavour (*info->symtab) != bfd_target_elf_flavour) return mstate; - /* Reset the last_map_symbol if we start to dump a new section. */ - if (memaddr <= 0) + /* Reset the last_map_symbol if the address is zero. */ + if (memaddr == 0) last_map_symbol = -1; /* If the last stop offset is different from the current one, then @@ -1195,7 +1193,6 @@ riscv_search_mapping_symbol (bfd_vma memaddr, if (riscv_get_map_state (n, &mstate, info, true)) { symbol = n; - found = true; break; } }