From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=irq.a4lg.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=irq.a4lg.com 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irq.a4lg.com; s=2017s01; t=1668906621; bh=b8rnXkxMJlHqqQ+XwmjUi9OsXY0Ji4YhRBWKPbh3SZQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Mime-Version:Content-Transfer-Encoding; b=PW+T9HtVgwP2OXZVUOeJ9iq+vqsrnAFAU6tQ5VoxL2te9V6lEE3GvC0xbJsM+fjYY bj9Mh+v6odHWIbRYi1z3+rd1OySDbk2gpo/xI8+Bkyg4IfOqsHKZn6oNdg7AC6vBen TXRmy1vpjv+HLKd/npou6YK1Dk3t6k0qM19NDpuU= From: Tsukasa OI 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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; } } -- 2.38.1