diff --git a/src/zipr.cpp b/src/zipr.cpp index 9179b47e3f2f9af47994fb423f4ecd4e397c6146..a3f6d3d20cdfe5292a0c797b05a917ca773079eb 100644 --- a/src/zipr.cpp +++ b/src/zipr.cpp @@ -3305,6 +3305,16 @@ RangeAddress_t ZiprImpl_t::_PlopDollopEntry(DollopEntry_t *entry, RangeAddress_t updated_addr = PlopDollopEntry(entry, placed_address, target_address); } + // sanity check that we aren't moving an instruction that's already been placed. + const auto old_loc=final_insn_locations[insn]; + if(old_loc != 0 && old_loc != placed_address ) + { + static int count=0; + cout<<"Warning, Moving instruction "<<hex<<insn->GetBaseID()<<":"<<insn->GetComment() + <<" from "<<hex<<old_loc<<" to "<<placed_address<<endl; + cout<<"Happened for "<<dec<<count++<<" out of "<<m_firp->GetInstructions().size()<<" instructions"<<endl; + } + final_insn_locations[insn] = placed_address; return updated_addr; } diff --git a/src/zipr_dollop_man.cpp b/src/zipr_dollop_man.cpp index a9a859546cde56cd8e6478288ecbd93fe4f6c8e9..e96a3ffd03d67c5d54e88c7e83486e3ab0647426 100644 --- a/src/zipr_dollop_man.cpp +++ b/src/zipr_dollop_man.cpp @@ -125,7 +125,13 @@ namespace zipr { * and link them together. */ previous_dollop = new_dollop; - new_dollop = Dollop_t::CreateNewDollop(fallthrough, this); + + // cannot do this: + // new_dollop = Dollop_t::CreateNewDollop(fallthrough, this); + // because CreateNewDollop does not adaquately trim the dollop + // and it might result in an instruction being in two dollops + // Using AddNewDollops instead. + new_dollop = this->AddNewDollops(fallthrough); previous_dollop->FallthroughDollop(new_dollop); new_dollop->FallbackDollop(previous_dollop); }