From 580226cfa0bcb5788410b93e4590ac642b7dd2aa Mon Sep 17 00:00:00 2001 From: caheckman <48068198+caheckman@users.noreply.github.com> Date: Mon, 30 Sep 2024 23:02:15 +0000 Subject: [PATCH] GP-4899 Full check for switch target in isDoNothing --- .../Features/Decompiler/src/decompile/cpp/block.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc b/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc index a24283890b..46da66dfa2 100644 --- a/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc +++ b/Ghidra/Features/Decompiler/src/decompile/cpp/block.cc @@ -2574,9 +2574,16 @@ bool BlockBasic::isDoNothing(void) const if (sizeIn() == 0) return false; // A block that does nothing but // is a starting block, may need to be a // placeholder for global(persistent) vars - if ((sizeIn()==1)&&(getIn(0)->isSwitchOut())) { - if (getOut(0)->sizeIn() > 1) - return false; // Don't remove switch targets + for(int4 i=0;iisSwitchOut()) continue; + if (switchbl->sizeOut() > 1) { + // This block is a switch target + if (getOut(0)->sizeIn() > 1) { // Multiple edges coming together + // Switch edge may still be propagating a unique value + return false; // Don't remove it + } + } } PcodeOp *lastop = lastOp(); if ((lastop != (PcodeOp *)0)&&(lastop->code()==CPUI_BRANCHIND))