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 2F1563854572 for ; Mon, 28 Nov 2022 04:44:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2F1563854572 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 7C2DC300089; Mon, 28 Nov 2022 04:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irq.a4lg.com; s=2017s01; t=1669610697; bh=zxufoScZ45JUF/v53XFfZpJIolVsqNg1wUdR4KqVktQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Mime-Version:Content-Transfer-Encoding; b=FXnvDa6QeU/vtFm+syIoOA+alvHv+975M70eQ1TZXNbewbLOm4ln7vrsolwo42eqS N9ri4hu9KLW2X4zIhJ+5Ft3Y65t79fuUzwrC41/vph8IHWiUBohCOSiMs7PFnotVv2 xrYFv+3aYLsSCEGAMgqAA4789B7HCBddInyfsmpQ= From: Tsukasa OI To: Tsukasa OI , Nelson Chu , Kito Cheng , Palmer Dabbelt Cc: binutils@sourceware.org Subject: [PATCH v2 05/11] RISC-V: One time CSR hash table initialization Date: Mon, 28 Nov 2022 04:43:40 +0000 Message-Id: <72c8e56861fccff6720a9b6ccefcecfd80e1adba.1669610611.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 The current disassembler intends to initialize the CSR hash table when CSR name parsing is required at the first time. This is managed by a function- scope static variable init_csr but... there's a problem. It's never set to true. Because of this issue, current disassembler actually initializes the CSR hash table every time when CSR name parsing is required. This commit sets init_csr to true once the CSR hash table is initialized. It is expected to have about 30% performance improvements alone when thousands of only CSR instructions are disassembled (CSR instructions are rare in general so real world performance improvement is not that high). This commit alone will not affect real world performance that much but after the efficient opcode hash is implemented, it will be much effective (sometimes >x10 effect than this commit alone) so that even some regular programs can benefit from it. opcodes/ChangeLog: * riscv-dis.c (print_insn_args): Make sure that CSR hash table initialization occurs only once. --- opcodes/riscv-dis.c | 1 + 1 file changed, 1 insertion(+) diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c index 38eb91349d9a..51a08d847b10 100644 --- a/opcodes/riscv-dis.c +++ b/opcodes/riscv-dis.c @@ -564,6 +564,7 @@ print_insn_args (const char *oparg, insn_t l, bfd_vma pc, disassemble_info *info DECLARE_CSR (name, num, class, define_version, abort_version) #include "opcode/riscv-opc.h" #undef DECLARE_CSR + init_csr = true; } if (riscv_csr_hash[csr] != NULL) -- 2.38.1