@@ -213,6 +213,8 @@ void Gia_ManOriginsDup( Gia_Man_t * pNew, Gia_Man_t * pOld )
213213 pNew -> vOrigins = Vec_IntStartFull ( Gia_ManObjNum (pNew ) );
214214 Gia_ManForEachObj ( pOld , pObj , i )
215215 {
216+ if ( i >= Vec_IntSize (pOld -> vOrigins ) )
217+ break ;
216218 if ( (int )Gia_ObjValue (pObj ) != -1 )
217219 {
218220 int iNew = Abc_Lit2Var ( Gia_ObjValue (pObj ) );
@@ -239,6 +241,24 @@ void Gia_ManOriginsDup( Gia_Man_t * pNew, Gia_Man_t * pOld )
239241 SeeAlso []
240242
241243***********************************************************************/
244+ void Gia_ManOriginsDupVec ( Gia_Man_t * pNew , Gia_Man_t * pOld , Vec_Int_t * vCopies )
245+ {
246+ int i , iLit ;
247+ if ( !pOld -> vOrigins )
248+ return ;
249+ pNew -> vOrigins = Vec_IntStartFull ( Gia_ManObjNum (pNew ) );
250+ Vec_IntForEachEntry ( vCopies , iLit , i )
251+ {
252+ if ( iLit != -1 )
253+ {
254+ int iNew = Abc_Lit2Var ( iLit );
255+ if ( iNew < Gia_ManObjNum (pNew ) && i < Vec_IntSize (pOld -> vOrigins ) )
256+ Vec_IntWriteEntry ( pNew -> vOrigins , iNew ,
257+ Vec_IntEntry (pOld -> vOrigins , i ) );
258+ }
259+ }
260+ }
261+
242262void Gia_ManOriginsAfterRoundTrip ( Gia_Man_t * pNew , Gia_Man_t * pOld )
243263{
244264 Gia_Obj_t * pObj ;
@@ -256,16 +276,18 @@ void Gia_ManOriginsAfterRoundTrip( Gia_Man_t * pNew, Gia_Man_t * pOld )
256276 {
257277 int iNewObj = Gia_ObjId ( pNew , pObj );
258278 int iOldCi = Gia_ObjId ( pOld , Gia_ManCi (pOld , i ) );
259- Vec_IntWriteEntry ( pNew -> vOrigins , iNewObj ,
260- Vec_IntEntry (pOld -> vOrigins , iOldCi ) );
279+ if ( iOldCi < Vec_IntSize (pOld -> vOrigins ) )
280+ Vec_IntWriteEntry ( pNew -> vOrigins , iNewObj ,
281+ Vec_IntEntry (pOld -> vOrigins , iOldCi ) );
261282 }
262283 // CO drivers map 1:1 (output correspondence preserved through optimization)
263284 Gia_ManForEachCo ( pNew , pObj , i )
264285 {
265286 int iNewDriver = Gia_ObjFaninId0p ( pNew , pObj );
266287 Gia_Obj_t * pOldCo = Gia_ManCo ( pOld , i );
267288 int iOldDriver = Gia_ObjFaninId0p ( pOld , pOldCo );
268- if ( iNewDriver > 0 && Vec_IntEntry (pNew -> vOrigins , iNewDriver ) == -1 )
289+ if ( iNewDriver > 0 && iOldDriver < Vec_IntSize (pOld -> vOrigins ) &&
290+ Vec_IntEntry (pNew -> vOrigins , iNewDriver ) == -1 )
269291 Vec_IntWriteEntry ( pNew -> vOrigins , iNewDriver ,
270292 Vec_IntEntry (pOld -> vOrigins , iOldDriver ) );
271293 }
@@ -928,11 +950,14 @@ Gia_Man_t * Gia_ManDupWithAttributes( Gia_Man_t * p )
928950 pNew -> vConfigs2 = Vec_StrDup ( p -> vConfigs2 );
929951 if ( p -> pCellStr )
930952 pNew -> pCellStr = Abc_UtilStrsav ( p -> pCellStr );
953+ // copy origins if present
954+ if ( p -> vOrigins )
955+ pNew -> vOrigins = Vec_IntDup ( p -> vOrigins );
931956 // copy names if present
932957 if ( p -> vNamesIn )
933958 pNew -> vNamesIn = Vec_PtrDupStr ( p -> vNamesIn );
934959 if ( p -> vNamesOut )
935- pNew -> vNamesOut = Vec_PtrDupStr ( p -> vNamesOut );
960+ pNew -> vNamesOut = Vec_PtrDupStr ( p -> vNamesOut );
936961 return pNew ;
937962}
938963Gia_Man_t * Gia_ManDupRemovePis ( Gia_Man_t * p , int nRemPis )
0 commit comments