From 56f80e10e32a3433cb7df9f2906568d481a5dc34 Mon Sep 17 00:00:00 2001 From: clc5q <clc5q@git.zephyr-software.com> Date: Wed, 21 Sep 2011 04:42:01 +0000 Subject: [PATCH] More cleanup of unreachable basic blocks. --- SMPFunction.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/SMPFunction.cpp b/SMPFunction.cpp index 4e1b2363..22d9aeb2 100644 --- a/SMPFunction.cpp +++ b/SMPFunction.cpp @@ -2548,12 +2548,25 @@ void SMPFunction::SetLinks(void) { if (!(this->HasIndirectJumps())) { #endif bool changed; + bool NoPredecessors; + bool OnlyPredIsItself; + list<list<SMPBasicBlock>::iterator>::iterator CurrPred; do { changed = false; CurrBlock = this->Blocks.begin(); ++CurrBlock; // don't delete the top block, no matter what. while (CurrBlock != this->Blocks.end()) { - if (CurrBlock->GetFirstPred() == CurrBlock->GetLastPred()) { + OnlyPredIsItself = false; + CurrPred = CurrBlock->GetFirstPred(); + NoPredecessors = (CurrPred == CurrBlock->GetLastPred()); + if (!NoPredecessors) { + if ((*CurrPred)->GetFirstAddr() == CurrBlock->GetFirstAddr()) { // self-recursion + ++CurrPred; // any more preds besides itself? + OnlyPredIsItself = (CurrPred == CurrBlock->GetLastPred()); + // Only predecessor was the self-recursion if no more preds + } + } + if (NoPredecessors || OnlyPredIsItself) { if (CurrBlock->AllNops()) msg("Removing all nops block at %x\n", CurrBlock->GetFirstAddr()); else @@ -2805,7 +2818,7 @@ int SMPFunction::IntersectDoms(int block1, int block2) const { void SMPFunction::ComputeIDoms(void) { bool DebugFlag = false; #if SMP_DEBUG_DATAFLOW - DebugFlag = (0 == strcmp("uw_frame_state_for", this->GetFuncName())); + DebugFlag = (0 == strcmp("_Z_St20__throw_system_errori", this->GetFuncName())); if (DebugFlag) msg("Entered ComputeIDoms\n"); #endif // Initialize the IDom[] vector to uninitialized values for all blocks. -- GitLab