[llvm] [BOLT] Safe NOOP size only on X86 (NFC) (PR #71307)

Vladislav Khmelevsky via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 5 01:36:04 PDT 2023


https://github.com/yota9 created https://github.com/llvm/llvm-project/pull/71307

Small fix, we have problems with noop size only on x86, no reason to do
it on other platforms.


>From fed7fe30c32e2747b8a3c77eae60ed49266d25cc Mon Sep 17 00:00:00 2001
From: Vladislav Khmelevsky <och95 at yandex.ru>
Date: Sun, 5 Nov 2023 12:33:11 +0400
Subject: [PATCH] [BOLT] Safe NOOP size only on X86 (NFC)

Small fix, we have problems with noop size only on x86, no reason to do
it on other platforms.
---
 bolt/lib/Core/BinaryFunction.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index 2e1fa739e53f20b..781f38f674dbf99 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -1375,8 +1375,8 @@ bool BinaryFunction::disassemble() {
     if (BC.keepOffsetForInstruction(Instruction))
       MIB->setOffset(Instruction, static_cast<uint32_t>(Offset));
 
-    if (BC.MIB->isNoop(Instruction)) {
-      // NOTE: disassembly loses the correct size information for noops.
+    if (BC.isX86() && BC.MIB->isNoop(Instruction)) {
+      // NOTE: disassembly loses the correct size information for noops on x86.
       //       E.g. nopw 0x0(%rax,%rax,1) is 9 bytes, but re-encoded it's only
       //       5 bytes. Preserve the size info using annotations.
       MIB->addAnnotation(Instruction, "Size", static_cast<uint32_t>(Size));



More information about the llvm-commits mailing list