From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-sender-0.a4lg.com (mail-sender-0.a4lg.com [IPv6:2401:2500:203:30b:4000:6bfe:4757:0]) by sourceware.org (Postfix) with ESMTPS id DC2D03954416 for ; Mon, 28 Nov 2022 04:47:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DC2D03954416 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 3C391300089; Mon, 28 Nov 2022 04:47:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irq.a4lg.com; s=2017s01; t=1669610858; bh=uAgpZsDVSo0FlFcs6R8Bh3QMLwLjF6ak+6JuXjkjWI0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Mime-Version:Content-Transfer-Encoding; b=YfFJ8bu3+tnpM2eDgy5PbopEGvgOc9Y1nWUlwisAD+u74vwvkWkstj/ldqJNN8I1j CYNLz6SfsKoy/wJrSHHPRYU5Jh6DV+6Trr1NoTDnf5MDwDFrXWDqC+opfRYYHmn5q9 Hd9tB93cikWZyyvkesMhm+HjMgq1d62dHZvRn6Gc= From: Tsukasa OI To: Tsukasa OI , Nelson Chu , Kito Cheng , Palmer Dabbelt Cc: binutils@sourceware.org Subject: [PATCH v2 1/3] RISC-V: Easy optimization on riscv_search_mapping_symbol Date: Mon, 28 Nov 2022 04:47:21 +0000 Message-Id: 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 eb3e64816bf6..bb7c03ad5fbf 100644 --- a/opcodes/riscv-dis.c +++ b/opcodes/riscv-dis.c @@ -1134,18 +1134,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 @@ -1197,7 +1195,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