[Lldb-commits] [lldb] [lldb] Remove some unreachable code (NFC) (PR #190529)

Sergei Barannikov via lldb-commits lldb-commits at lists.llvm.org
Sun Apr 5 07:50:54 PDT 2026


https://github.com/s-barannikov created https://github.com/llvm/llvm-project/pull/190529

`isRISCV()` check always returns false because we only get here if `min_op_byte_size` and `max_op_byte_size` are equal, which is not true for RISC-V.

>From 46defd776d6c0a395d2c581351acc1c814dadae5 Mon Sep 17 00:00:00 2001
From: Sergei Barannikov <barannikov88 at gmail.com>
Date: Sun, 5 Apr 2026 17:50:09 +0300
Subject: [PATCH] [lldb] Remove some unreachable code (NFC)

`isRISCV()` check always returns false because we only get here if
`min_op_byte_size` and `max_op_byte_size` are equal, which is not true
for RISC-V.
---
 .../Disassembler/LLVMC/DisassemblerLLVMC.cpp   | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
index 571340210a2db..534f04804e811 100644
--- a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
+++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp
@@ -459,7 +459,6 @@ class InstructionLLVMC : public lldb_private::Instruction {
                 lldb::offset_t data_offset) override {
     // All we have to do is read the opcode which can be easy for some
     // architectures
-    bool got_op = false;
     DisassemblerScope disasm(*this);
     if (disasm) {
       const ArchSpec &arch = disasm->GetArchitecture();
@@ -475,37 +474,26 @@ class InstructionLLVMC : public lldb_private::Instruction {
         switch (min_op_byte_size) {
         case 1:
           m_opcode.SetOpcode8(data.GetU8(&data_offset), byte_order);
-          got_op = true;
           break;
 
         case 2:
           m_opcode.SetOpcode16(data.GetU16(&data_offset), byte_order);
-          got_op = true;
           break;
 
         case 4:
           m_opcode.SetOpcode32(data.GetU32(&data_offset), byte_order);
-          got_op = true;
           break;
 
         case 8:
           m_opcode.SetOpcode64(data.GetU64(&data_offset), byte_order);
-          got_op = true;
           break;
 
         default:
-          if (arch.GetTriple().isRISCV())
-            m_opcode.SetOpcode16_32TupleBytes(
-                data.PeekData(data_offset, min_op_byte_size), min_op_byte_size,
-                byte_order);
-          else
-            m_opcode.SetOpcodeBytes(
-                data.PeekData(data_offset, min_op_byte_size), min_op_byte_size);
-          got_op = true;
+          m_opcode.SetOpcodeBytes(data.PeekData(data_offset, min_op_byte_size),
+                                  min_op_byte_size);
           break;
         }
-      }
-      if (!got_op) {
+      } else {
         bool is_alternate_isa = false;
         DisassemblerLLVMC::MCDisasmInstance *mc_disasm_ptr =
             GetDisasmToUse(is_alternate_isa, disasm);



More information about the lldb-commits mailing list