[llvm] [BOLT][AArch64] Speedup `computeInstructionSize` (PR #121106)

via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 25 03:53:50 PST 2024


https://github.com/liusy58 updated https://github.com/llvm/llvm-project/pull/121106

>From b4c9c4ceaadbee099eaf3267492d0f873965e67b Mon Sep 17 00:00:00 2001
From: liusy58 <liusy58 at linux.alibaba.com>
Date: Wed, 25 Dec 2024 19:45:08 +0800
Subject: [PATCH] [BOLT][AArch64]  Speedup `computeInstructionSize`

---
 bolt/include/bolt/Core/BinaryContext.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/bolt/include/bolt/Core/BinaryContext.h b/bolt/include/bolt/Core/BinaryContext.h
index 115e59ca0697e5..f644b4b2c3b4c5 100644
--- a/bolt/include/bolt/Core/BinaryContext.h
+++ b/bolt/include/bolt/Core/BinaryContext.h
@@ -1363,6 +1363,17 @@ class BinaryContext {
     if (std::optional<uint32_t> Size = MIB->getSize(Inst))
       return *Size;
 
+    // Pseudo instrs will not be emiitted and have no size.
+    if (MIB->isPseudo(Inst)) {
+      return 0;
+    }
+
+    // Directly return 4 because AArch64 instructions always have a
+    // fixed size of 4 bytes.
+    if (isAArch64()) {
+      return 4;
+    }
+
     if (!Emitter)
       Emitter = this->MCE.get();
     SmallString<256> Code;



More information about the llvm-commits mailing list