Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coverity fix, missing break #6327

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/dbSta/include/db_sta/dbNetwork.hh
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class dbNetwork : public ConcreteNetwork
dbBTerm*& bterm,
dbModITerm*& moditerm,
dbModBTerm*& modbterm) const;
dbITerm* staToDb(const Pin* pin) const;

dbNet* staToDb(const Net* net) const;
void staToDb(const Net* net, dbNet*& dnet, dbModNet*& modnet) const;
Expand Down
17 changes: 17 additions & 0 deletions src/dbSta/src/dbNetwork.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2339,6 +2339,23 @@ void dbNetwork::staToDb(const Pin* pin,
}
}

// Get the iterm for a pin and error check
dbITerm* dbNetwork::staToDb(const Pin* pin) const
{
dbITerm* ret = nullptr;
if (pin) {
dbObject* obj = reinterpret_cast<dbObject*>(const_cast<Pin*>(pin));
dbObjectType type = obj->getObjectType();
if (type == dbITermObj) {
ret = static_cast<dbITerm*>(obj);
}
}
if (ret == nullptr) {
logger_->critical(ORD, 2023, "pin is not an ITerm");
}
return ret;
}

dbBTerm* dbNetwork::staToDb(const Term* term) const
{
return reinterpret_cast<dbBTerm*>(const_cast<Term*>(term));
Expand Down
2 changes: 2 additions & 0 deletions src/odb/src/db/dbJournal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1778,8 +1778,10 @@ void dbJournal::undo_swapObject()
467,
"No undo_swapObject Name support for type {}",
dbObject::getTypeName(sub_obj_type));
break;
}
}
break;
}
case dbInstObj: {
uint inst_id;
Expand Down
94 changes: 44 additions & 50 deletions src/rsz/src/Resizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -629,35 +629,33 @@ void Resizer::getPins(Instance* inst, PinVector& pins) const

void Resizer::SwapNetNames(odb::dbITerm* iterm_to, odb::dbITerm* iterm_from)
{
if (iterm_to && iterm_from) {
//
// The concept of this function is we are moving the name of the net
// in the iterm_from to the iterm_to. We preferentially use
// the modnet name, if present.
//
dbNet* to_db_net = iterm_to->getNet();
odb::dbModNet* to_mod_net = iterm_to->getModNet();
//
// The concept of this function is we are moving the name of the net
// in the iterm_from to the iterm_to. We preferentially use
// the modnet name, if present.
//
dbNet* to_db_net = iterm_to->getNet();
odb::dbModNet* to_mod_net = iterm_to->getModNet();

odb::dbModNet* from_mod_net = iterm_from->getModNet();
dbNet* from_db_net = iterm_from->getNet();
odb::dbModNet* from_mod_net = iterm_from->getModNet();
dbNet* from_db_net = iterm_from->getNet();

std::string required_name
= from_mod_net ? from_mod_net->getName() : from_db_net->getName();
std::string to_name
= to_mod_net ? to_mod_net->getName() : to_db_net->getName();
std::string required_name
= from_mod_net ? from_mod_net->getName() : from_db_net->getName();
std::string to_name
= to_mod_net ? to_mod_net->getName() : to_db_net->getName();

if (from_mod_net && to_mod_net) {
from_mod_net->rename(to_name.c_str());
to_mod_net->rename(required_name.c_str());
} else if (from_db_net && to_db_net) {
to_db_net->swapNetNames(from_db_net);
} else if (from_mod_net && to_db_net) {
to_db_net->rename(required_name.c_str());
from_mod_net->rename(to_name.c_str());
} else if (to_mod_net && from_db_net) {
to_mod_net->rename(required_name.c_str());
from_db_net->rename(to_name.c_str());
}
if (from_mod_net && to_mod_net) {
from_mod_net->rename(to_name.c_str());
to_mod_net->rename(required_name.c_str());
} else if (from_db_net && to_db_net) {
to_db_net->swapNetNames(from_db_net);
} else if (from_mod_net && to_db_net) {
to_db_net->rename(required_name.c_str());
from_mod_net->rename(to_name.c_str());
} else if (to_mod_net && from_db_net) {
to_mod_net->rename(required_name.c_str());
from_db_net->rename(to_name.c_str());
}
}

Expand Down Expand Up @@ -914,31 +912,27 @@ void Resizer::bufferOutput(const Pin* top_pin, LibertyCell* buffer_cell)
Pin* buffer_op_pin = nullptr;
getBufferPins(buffer, buffer_ip_pin, buffer_op_pin);

// get the iterms. Note this are never null (makeBuffer properly instantiates
// them and we know to always expect an iterm.). However, the api (flatPin)
// truly checks to see if the pins could be moditerms & if they are returns
// null, so coverity rationally reasons that the iterm could be null,
// so we add some extra checking here. This is a consequence of
//"hiding" the full api.
//
odb::dbITerm* buffer_op_pin_iterm = db_network_->flatPin(buffer_op_pin);
odb::dbITerm* buffer_ip_pin_iterm = db_network_->flatPin(buffer_ip_pin);
// get the iterm for each of the buffer pins
// use the db converter function (staToDb) which error checks.
odb::dbITerm* buffer_ip_pin_iterm = db_network_->staToDb(buffer_ip_pin);
odb::dbITerm* buffer_op_pin_iterm = db_network_->staToDb(buffer_op_pin);

if (buffer_ip_pin_iterm && buffer_op_pin_iterm) {
if (flat_op_net) {
buffer_ip_pin_iterm->connect(flat_op_net);
}
if (hier_op_net) {
buffer_ip_pin_iterm->connect(hier_op_net);
}
buffer_op_pin_iterm->connect(db_network_->staToDb(buffer_out));
top_pin_op_bterm->connect(db_network_->staToDb(buffer_out));
SwapNetNames(buffer_op_pin_iterm, buffer_ip_pin_iterm);
// rename the mod net to match the flat net.
if (buffer_ip_pin_iterm->getNet() && buffer_ip_pin_iterm->getModNet()) {
buffer_ip_pin_iterm->getModNet()->rename(
buffer_ip_pin_iterm->getNet()->getName().c_str());
}
assert(buffer_ip_pin_iterm != nullptr);
assert(buffer_op_pin_iterm != nullptr);

if (flat_op_net) {
buffer_ip_pin_iterm->connect(flat_op_net);
}
if (hier_op_net) {
buffer_ip_pin_iterm->connect(hier_op_net);
}
buffer_op_pin_iterm->connect(db_network_->staToDb(buffer_out));
top_pin_op_bterm->connect(db_network_->staToDb(buffer_out));
SwapNetNames(buffer_op_pin_iterm, buffer_ip_pin_iterm);
// rename the mod net to match the flat net.
if (buffer_ip_pin_iterm->getNet() && buffer_ip_pin_iterm->getModNet()) {
buffer_ip_pin_iterm->getModNet()->rename(
buffer_ip_pin_iterm->getNet()->getName().c_str());
}

parasiticsInvalid(flat_op_net);
Expand Down
Loading