Commit f8641a5
committed
Multi-origin vOrigins with inline small-buffer optimization
Replace single-origin-per-object vOrigins with a union-based scheme
that stores up to GIA_ORIGINS_INLINE (default 4) origins inline, with
overflow to a heap-allocated array for outliers. This captures merge
events from structural hashing and optimization that previously lost
origin information.
Data structure (Gia_OriginsEntry_t union, 16 bytes on 64-bit):
- Small mode: 4 inline int slots (-1 = unused)
- Large mode: sentinel (INT_MIN) + count + heap pointer
- Stride = sizeof(entry)/sizeof(int) = 4 ints per object
Key changes:
- gia.h: Union type, stride constants, inline accessors
(Gia_ObjOriginsNum, Gia_ObjOriginsGet, Gia_ObjForEachOrigin),
updated Gia_ObjOrigin/Gia_ObjSetOrigin for backward compat
- giaDup.c: Gia_ObjAddOrigin (dedup + promote), Gia_ObjUnionOrigins,
Gia_ManOriginsFreeOverflows; updated OriginsDup/DupVec/AfterRoundTrip
for strided multi-origin propagation
- giaHash.c: Union all input origins on hash miss AND hash hit (captures
structural sharing from different source paths)
- giaAiger.c: Variable-length "y" extension format [count, lit0, lit1,...]
with backward-compatible reader for old single-origin format
- giaIf.c, giaMfs.c: Mapper propagation via Gia_ObjUnionOrigins
- giaMan.c: Free overflow arrays before vOrigins cleanup
Co-developed-by: Claude Code v2.1.58 (claude-opus-4-6)
Harden multi-origin vOrigins: leak guards, geometric growth, format sentinel
- Add free-before-alloc guards in all OriginsDup functions to prevent
memory leaks when vOrigins is already populated (e.g. Gia_ManDup
followed by Gia_ManDupWithAttributes)
- Replace O(n²) realloc-by-1 with geometric doubling in overflow
arrays (8-slot initial capacity, double at powers of 2)
- Add sentinel int -2 to AIGER "y" extension writer/reader for
unambiguous new-vs-old format detection (fixes edge case where
nInts == nAigObjs with all-zero origins)
- Extract Gia_ManOriginsDupIf() helper to deduplicate 3 identical
14-line IF mapper origin propagation blocks
- Replace Gia_ManOriginsGrow push-loop with Vec_IntFillExtra
- Add vNodes NULL guard in AIGER reader
- Remove orphaned duplicate comment block
Co-developed-by: Claude Code v2.1.58 (claude-opus-4-6)
Simplify vOrigins: extract OriginsReset, fix free(), hoist iteration count
Code review cleanup:
- Extract Gia_ManOriginsReset() helper to replace 5 identical
free-overflows + free-vec leak-guard blocks
- Use ABC_FREE() instead of bare free() in Gia_ObjSetOrigin
for allocator consistency
- Hoist Gia_ObjOriginsNum() call out of Gia_ObjForEachOrigin
macro loop condition (callers declare _nOrig)
- Add compile-time assertion that GIA_ORIGINS_INLINE is large
enough to cover the overflow header on the target platform
Co-developed-by: Claude Code v2.1.83 (claude-opus-4-6)1 parent acaa07e commit f8641a5
7 files changed
Lines changed: 388 additions & 127 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
48 | 77 | | |
49 | 78 | | |
50 | 79 | | |
| |||
463 | 492 | | |
464 | 493 | | |
465 | 494 | | |
466 | | - | |
467 | | - | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
468 | 566 | | |
469 | 567 | | |
470 | 568 | | |
| |||
1352 | 1450 | | |
1353 | 1451 | | |
1354 | 1452 | | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
1355 | 1457 | | |
1356 | 1458 | | |
1357 | 1459 | | |
| 1460 | + | |
1358 | 1461 | | |
1359 | 1462 | | |
1360 | 1463 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
942 | 942 | | |
943 | 943 | | |
944 | 944 | | |
945 | | - | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
946 | 969 | | |
947 | 970 | | |
948 | | - | |
| 971 | + | |
949 | 972 | | |
950 | 973 | | |
951 | 974 | | |
952 | 975 | | |
953 | 976 | | |
954 | 977 | | |
955 | | - | |
| 978 | + | |
956 | 979 | | |
957 | 980 | | |
958 | 981 | | |
| |||
1836 | 1859 | | |
1837 | 1860 | | |
1838 | 1861 | | |
| 1862 | + | |
1839 | 1863 | | |
1840 | 1864 | | |
1841 | 1865 | | |
1842 | | - | |
1843 | | - | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
1844 | 1869 | | |
1845 | 1870 | | |
1846 | | - | |
1847 | | - | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
1848 | 1876 | | |
1849 | 1877 | | |
1850 | | - | |
1851 | | - | |
1852 | | - | |
1853 | | - | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
1854 | 1883 | | |
1855 | 1884 | | |
1856 | 1885 | | |
| |||
0 commit comments