Skip to content

Commit

Permalink
Modified the cell copy routine so that it does not attempt to
Browse files Browse the repository at this point in the history
guarantee unique instance names during generation of each new
copy, but only afterward, in bulk.  Otherwise the copy routine
has a runtime that is exponential with the number of cells being
copied.  This and the last commit guarantee that the "flatten
-novendor" option works as advertised.
  • Loading branch information
RTimothyEdwards committed Sep 7, 2022
1 parent 4087ac2 commit 84b4297
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
17 changes: 8 additions & 9 deletions database/DBcellcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1209,6 +1209,10 @@ DBCellCopyAllCells(scx, xMask, targetUse, pArea)
GeoTransRect(&scx->scx_trans, &scx->scx_area, &arg.caa_rect);

(void) DBTreeSrCells(scx, xMask, dbCellCopyCellsFunc, (ClientData) &arg);

/* dbCellCopyCellsFunc() allows cells to be left with duplicate IDs */
/* so generate unique IDs as needed now. */
DBGenerateUniqueIds(targetUse->cu_def, FALSE);
}

/*
Expand Down Expand Up @@ -1306,17 +1310,12 @@ dbCellCopyCellsFunc(scx, arg)
return 2;
}

/* When creating a new use, try to re-use the id from the old
* one. Only create a new one if the old id can't be used.
*/
/* When creating a new use, re-use the id from the old one. */
/* Do not attempt to run DBLinkCell() now and resolve unique IDs; */
/* just create duplicate IDs and regenerate unique ones at the end. */

newUse = DBCellNewUse(def, (char *) use->cu_id);
if (!DBLinkCell(newUse, arg->caa_targetUse->cu_def))
{
freeMagic((char *) newUse->cu_id);
newUse->cu_id = NULL;
(void) DBLinkCell(newUse, arg->caa_targetUse->cu_def);
}

newUse->cu_expandMask = use->cu_expandMask;
newUse->cu_flags = use->cu_flags;

Expand Down
13 changes: 11 additions & 2 deletions database/DBcellname.c
Original file line number Diff line number Diff line change
Expand Up @@ -2098,6 +2098,14 @@ DBCellSrDefs(pattern, func, cdata)
* This operation is not recorded on the undo list, as it always accompanies
* the creation of a new cell use.
*
* *** ANOTHER WARNING ***
*
* Do NOT pass a NULL cu_id to this routine when doing bulk cell copies,
* because an entire hash table of entries for the parent def will be created
* and searched for every cell being linked, making the routine run-time
* exponential with the number of links. It is better to run
* DBGenerateUniqueIDs() instead.
*
* Results:
* TRUE if the CellUse is unique within the parent CellDef, FALSE
* if there would be a name conflict. If the cu_id of the CellUse
Expand Down Expand Up @@ -2363,8 +2371,9 @@ dbFindNamesFunc(use, parentDef)
he = HashFind(&dbUniqueNameTable, use->cu_id);
if (HashGetValue(he))
{
TxError("Duplicate instance-id for cell %s (%s) will be renamed\n",
use->cu_def->cd_name, use->cu_id);
if (dbWarnUniqueIds)
TxError("Duplicate instance-id for cell %s (%s) will be renamed\n",
use->cu_def->cd_name, use->cu_id);
DBUnLinkCell(use, parentDef);
freeMagic(use->cu_id);
use->cu_id = (char *) NULL;
Expand Down

0 comments on commit 84b4297

Please # to comment.