@@ -212,6 +212,8 @@ void Gia_ManOriginsDup( Gia_Man_t * pNew, Gia_Man_t * pOld )
212212 pNew -> vOrigins = Vec_IntStartFull ( Gia_ManObjNum (pNew ) );
213213 Gia_ManForEachObj ( pOld , pObj , i )
214214 {
215+ if ( i >= Vec_IntSize (pOld -> vOrigins ) )
216+ break ;
215217 if ( (int )Gia_ObjValue (pObj ) != -1 )
216218 {
217219 int iNew = Abc_Lit2Var ( Gia_ObjValue (pObj ) );
@@ -238,6 +240,24 @@ void Gia_ManOriginsDup( Gia_Man_t * pNew, Gia_Man_t * pOld )
238240 SeeAlso []
239241
240242***********************************************************************/
243+ void Gia_ManOriginsDupVec ( Gia_Man_t * pNew , Gia_Man_t * pOld , Vec_Int_t * vCopies )
244+ {
245+ int i , iLit ;
246+ if ( !pOld -> vOrigins )
247+ return ;
248+ pNew -> vOrigins = Vec_IntStartFull ( Gia_ManObjNum (pNew ) );
249+ Vec_IntForEachEntry ( vCopies , iLit , i )
250+ {
251+ if ( iLit != -1 )
252+ {
253+ int iNew = Abc_Lit2Var ( iLit );
254+ if ( iNew < Gia_ManObjNum (pNew ) && i < Vec_IntSize (pOld -> vOrigins ) )
255+ Vec_IntWriteEntry ( pNew -> vOrigins , iNew ,
256+ Vec_IntEntry (pOld -> vOrigins , i ) );
257+ }
258+ }
259+ }
260+
241261void Gia_ManOriginsAfterRoundTrip ( Gia_Man_t * pNew , Gia_Man_t * pOld )
242262{
243263 Gia_Obj_t * pObj ;
@@ -255,16 +275,18 @@ void Gia_ManOriginsAfterRoundTrip( Gia_Man_t * pNew, Gia_Man_t * pOld )
255275 {
256276 int iNewObj = Gia_ObjId ( pNew , pObj );
257277 int iOldCi = Gia_ObjId ( pOld , Gia_ManCi (pOld , i ) );
258- Vec_IntWriteEntry ( pNew -> vOrigins , iNewObj ,
259- Vec_IntEntry (pOld -> vOrigins , iOldCi ) );
278+ if ( iOldCi < Vec_IntSize (pOld -> vOrigins ) )
279+ Vec_IntWriteEntry ( pNew -> vOrigins , iNewObj ,
280+ Vec_IntEntry (pOld -> vOrigins , iOldCi ) );
260281 }
261282 // CO drivers map 1:1 (output correspondence preserved through optimization)
262283 Gia_ManForEachCo ( pNew , pObj , i )
263284 {
264285 int iNewDriver = Gia_ObjFaninId0p ( pNew , pObj );
265286 Gia_Obj_t * pOldCo = Gia_ManCo ( pOld , i );
266287 int iOldDriver = Gia_ObjFaninId0p ( pOld , pOldCo );
267- if ( iNewDriver > 0 && Vec_IntEntry (pNew -> vOrigins , iNewDriver ) == -1 )
288+ if ( iNewDriver > 0 && iOldDriver < Vec_IntSize (pOld -> vOrigins ) &&
289+ Vec_IntEntry (pNew -> vOrigins , iNewDriver ) == -1 )
268290 Vec_IntWriteEntry ( pNew -> vOrigins , iNewDriver ,
269291 Vec_IntEntry (pOld -> vOrigins , iOldDriver ) );
270292 }
@@ -927,11 +949,14 @@ Gia_Man_t * Gia_ManDupWithAttributes( Gia_Man_t * p )
927949 pNew -> vConfigs2 = Vec_StrDup ( p -> vConfigs2 );
928950 if ( p -> pCellStr )
929951 pNew -> pCellStr = Abc_UtilStrsav ( p -> pCellStr );
952+ // copy origins if present
953+ if ( p -> vOrigins )
954+ pNew -> vOrigins = Vec_IntDup ( p -> vOrigins );
930955 // copy names if present
931956 if ( p -> vNamesIn )
932957 pNew -> vNamesIn = Vec_PtrDupStr ( p -> vNamesIn );
933958 if ( p -> vNamesOut )
934- pNew -> vNamesOut = Vec_PtrDupStr ( p -> vNamesOut );
959+ pNew -> vNamesOut = Vec_PtrDupStr ( p -> vNamesOut );
935960 return pNew ;
936961}
937962Gia_Man_t * Gia_ManDupRemovePis ( Gia_Man_t * p , int nRemPis )
@@ -4034,6 +4059,7 @@ Gia_Man_t * Gia_ManDupWithConstraints( Gia_Man_t * p, Vec_Int_t * vPoTypes )
40344059 Gia_ManForEachRi ( p , pObj , i )
40354060 pObj -> Value = Gia_ManAppendCo ( pNew , Gia_ObjFanin0Copy (pObj ) );
40364061// Gia_ManDupRemapEquiv( pNew, p );
4062+ Gia_ManOriginsDup ( pNew , p );
40374063 Gia_ManSetRegNum ( pNew , Gia_ManRegNum (p ) );
40384064 pNew -> nConstrs = nConstr ;
40394065 assert ( Gia_ManIsNormalized (pNew ) );
0 commit comments