From 03782c86ce227cf2db61792b4bc839daf1b02852 Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sat, 25 Apr 2026 23:07:32 +0000 Subject: [PATCH 1/2] Added test lifted from yosys demonstrating a bus error on sparc64. --- test/CMakeLists.txt | 4 ++- test/sparc-alignment/CMakeLists.txt | 6 +++++ test/sparc-alignment/abc.script | 32 ++++++++++++++++++++++ test/sparc-alignment/aligntest.sh | 10 +++++++ test/sparc-alignment/input.box | 40 ++++++++++++++++++++++++++++ test/sparc-alignment/input.lut | 14 ++++++++++ test/sparc-alignment/input.sym | 16 +++++++++++ test/sparc-alignment/input.xaig | Bin 0 -> 347 bytes 8 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 test/sparc-alignment/CMakeLists.txt create mode 100644 test/sparc-alignment/abc.script create mode 100755 test/sparc-alignment/aligntest.sh create mode 100644 test/sparc-alignment/input.box create mode 100644 test/sparc-alignment/input.lut create mode 100644 test/sparc-alignment/input.sym create mode 100644 test/sparc-alignment/input.xaig diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5a187fcac7..e4e3cd3d2a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1 +1,3 @@ -add_subdirectory(gia) \ No newline at end of file +add_subdirectory(gia) +add_subdirectory(sparc-alignment) + diff --git a/test/sparc-alignment/CMakeLists.txt b/test/sparc-alignment/CMakeLists.txt new file mode 100644 index 0000000000..1ed4c3aec1 --- /dev/null +++ b/test/sparc-alignment/CMakeLists.txt @@ -0,0 +1,6 @@ +#enable_testing() + +add_test(NAME aligntest + COMMAND ./aligntest.sh + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} +) diff --git a/test/sparc-alignment/abc.script b/test/sparc-alignment/abc.script new file mode 100644 index 0000000000..9d3811790f --- /dev/null +++ b/test/sparc-alignment/abc.script @@ -0,0 +1,32 @@ +echo + read_lut "input.lut"; +read_lut "input.lut"; +echo + read_box "input.box"; +read_box "input.box"; +echo + &read input.xaig; +&read input.xaig; +echo + &ps; +&ps; +echo + &scorr; +&scorr; +echo + &sweep; +&sweep; +echo + &dc2; +&dc2; +echo + &dch -f -r; +&dch -f -r; +echo + &ps; +&ps; +echo + &if -W 300 -v; +&if -W 300 -v; +echo + &write -n output.aig; +&write -n output.aig; +echo + &mfs; +&mfs; +echo + &ps -l; +&ps -l; +echo + &write -n output.aig; +&write -n output.aig; +echo + &verify; +&verify; +echo + time; +time diff --git a/test/sparc-alignment/aligntest.sh b/test/sparc-alignment/aligntest.sh new file mode 100755 index 0000000000..f9741b3ac9 --- /dev/null +++ b/test/sparc-alignment/aligntest.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# Run test lifted from yosys demonstrating bus error on sparc64. + +PATH=`pwd`/../..:$PATH +export PATH + +cd $(dirname $0) + +abc -s -f abc.script diff --git a/test/sparc-alignment/input.box b/test/sparc-alignment/input.box new file mode 100644 index 0000000000..62b0c67cc8 --- /dev/null +++ b/test/sparc-alignment/input.box @@ -0,0 +1,40 @@ +$__DFF_P__$abc9_flop 1 1 3 1 +#C D Q +0 0 0 # $_DFF_[NP]_.D + +$__DFF_N__$abc9_flop 2 1 3 1 +#C D Q +0 0 0 # $_DFF_[NP]_.D + +$__ABC9_DELAY 3 0 1 1 +#I +0 # O + +CCU2C 4 1 9 3 +#A0 B0 C0 D0 A1 B1 C1 D1 CIN +379 379 275 141 - - - - 257 # S0 +630 630 526 392 379 379 275 141 273 # S1 +516 516 412 278 516 516 412 278 43 # COUT + +DPR16X4C 5 1 14 4 +#DI[0] DI[1] DI[2] DI[3] WCK WRE RAD[0] RAD[1] RAD[2] RAD[3] WAD[0] WAD[1] WAD[2] WAD[3] +- - - - - - 0 0 0 0 - - - - # DO[0] +- - - - - - 0 0 0 0 - - - - # DO[1] +- - - - - - 0 0 0 0 - - - - # DO[2] +- - - - - - 0 0 0 0 - - - - # DO[3] + +TRELLIS_DPR16X4 6 1 14 4 +#DI[0] DI[1] DI[2] DI[3] WAD[0] WAD[1] WAD[2] WAD[3] WRE WCK RAD[0] RAD[1] RAD[2] RAD[3] +- - - - - - - - - - 0 0 0 0 # DO[0] +- - - - - - - - - - 0 0 0 0 # DO[1] +- - - - - - - - - - 0 0 0 0 # DO[2] +- - - - - - - - - - 0 0 0 0 # DO[3] + +PFUMX 7 1 3 1 +#ALUT BLUT C0 +98 98 151 # Z + +L6MUX21 8 1 3 1 +#D0 D1 SD +140 141 148 # Z + diff --git a/test/sparc-alignment/input.lut b/test/sparc-alignment/input.lut new file mode 100644 index 0000000000..0e8b9787c3 --- /dev/null +++ b/test/sparc-alignment/input.lut @@ -0,0 +1,14 @@ +# $__ABC9_LUT1 +1 1 141 +# $__ABC9_LUT2 +2 1 141 275 +# $__ABC9_LUT3 +3 1 141 275 379 +# LUT4 +4 1 141 275 379 379 +# \$__ABC9_LUT5 +5 2 151 239 373 477 477 +# \$__ABC9_LUT6 +6 4 148 292 380 514 618 618 +# \$__ABC9_LUT7 +7 8 148 289 433 521 655 759 759 diff --git a/test/sparc-alignment/input.sym b/test/sparc-alignment/input.sym new file mode 100644 index 0000000000..8f17ed2140 --- /dev/null +++ b/test/sparc-alignment/input.sym @@ -0,0 +1,16 @@ +input 0 0 x +input 1 1 x +input 2 2 x +input 3 3 x +input 4 0 y +input 5 1 y +input 6 2 y +input 7 3 y +output 0 0 A +output 1 1 A +output 2 2 A +output 3 3 A +output 4 0 B +output 5 1 B +output 6 2 B +output 7 3 B diff --git a/test/sparc-alignment/input.xaig b/test/sparc-alignment/input.xaig new file mode 100644 index 0000000000000000000000000000000000000000..7393015c62a9853d0a65869c88bd90b205b3a836 GIT binary patch literal 347 zcmaKkF;BxV5QSs6Rc#AY28OcT*bY!TahzsC0tp5tB$f&>IPtZ$)TSuOK>j@^5JF<$ zr0?myC%yA=2QG&-Xd*9EnySpH+^Ql~MX5@wj7gQrv=TxJ#?Qn#>80RKH9D@q_P z$g}Bq!uUcgsnKFK{b_FH9r=6tK>8$^V3YBP@n`u$c_U}E`CfV%sEP7-S?`l1nG=i< ze@G$~K>T};*kJ2>3{VZQIdww^`o>vU>|zhy-WzZst*y;HRv{}=XM)Bo!(c Date: Sat, 25 Apr 2026 23:08:06 +0000 Subject: [PATCH 2/2] Fix some alignment issues on arm, hppa and sparc. --- Makefile | 3 --- src/aig/aig/aigTsim.c | 2 +- src/map/if/ifMan.c | 7 ++++--- src/misc/util/abc_global.h | 21 +++++++++++++++++++++ src/opt/rwt/rwtMan.c | 2 +- 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index adb8ee3029..7f2c7be9de 100644 --- a/Makefile +++ b/Makefile @@ -74,9 +74,6 @@ ARCHFLAGS := $(ARCHFLAGS) OPTFLAGS ?= -g -O CFLAGS += -Wall -Wno-unused-function -Wno-write-strings -Wno-sign-compare $(ARCHFLAGS) -ifneq ($(findstring arm,$(shell uname -m)),) - CFLAGS += -DABC_MEMALIGN=4 -endif # compile ABC using the C++ compiler and put everything in the namespace $(ABC_NAMESPACE) ifdef ABC_USE_NAMESPACE diff --git a/src/aig/aig/aigTsim.c b/src/aig/aig/aigTsim.c index dd9eb6e726..45c52369c2 100644 --- a/src/aig/aig/aigTsim.c +++ b/src/aig/aig/aigTsim.c @@ -135,7 +135,7 @@ Aig_Tsi_t * Aig_TsiStart( Aig_Man_t * pAig ) p->pAig = pAig; p->nWords = Abc_BitWordNum( 2*Aig_ManRegNum(pAig) ); p->vStates = Vec_PtrAlloc( 1000 ); - p->pMem = Aig_MmFixedStart( sizeof(unsigned) * p->nWords + sizeof(unsigned *), 10000 ); + p->pMem = Aig_MmFixedStart( alignPad(sizeof(unsigned) * p->nWords + sizeof(unsigned *)), 10000 ); p->nBins = Abc_PrimeCudd(TSI_MAX_ROUNDS/2); p->pBins = ABC_ALLOC( unsigned *, p->nBins ); memset( p->pBins, 0, sizeof(unsigned *) * p->nBins ); diff --git a/src/map/if/ifMan.c b/src/map/if/ifMan.c index ba5601fe85..3cca9b227f 100644 --- a/src/map/if/ifMan.c +++ b/src/map/if/ifMan.c @@ -88,9 +88,10 @@ If_Man_t * If_ManStart( If_Par_t * pPars ) } } p->nPermWords = p->pPars->fUsePerm? If_CutPermWords( p->pPars->nLutSize ) : 0; - p->nObjBytes = sizeof(If_Obj_t) + sizeof(int) * (p->pPars->nLutSize + p->nPermWords); - p->nCutBytes = sizeof(If_Cut_t) + sizeof(int) * (p->pPars->nLutSize + p->nPermWords); - p->nSetBytes = sizeof(If_Set_t) + (sizeof(If_Cut_t *) + p->nCutBytes) * (p->pPars->nCutsMax + 1); + p->nObjBytes = alignPad(sizeof(If_Obj_t) + sizeof(int) * (p->pPars->nLutSize + p->nPermWords)); + p->nCutBytes = alignPad(sizeof(If_Cut_t) + sizeof(int) * (p->pPars->nLutSize + p->nPermWords)); + p->nSetBytes = alignPad(sizeof(If_Set_t) + (sizeof(If_Cut_t *) + p->nCutBytes) * (p->pPars->nCutsMax + 1)); + p->pMemObj = Mem_FixedStart( p->nObjBytes ); // report expected memory usage if ( p->pPars->fVerbose ) diff --git a/src/misc/util/abc_global.h b/src/misc/util/abc_global.h index c5a0327e04..8c0429d753 100644 --- a/src/misc/util/abc_global.h +++ b/src/misc/util/abc_global.h @@ -271,6 +271,27 @@ typedef ABC_INT64_T iword; ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (size_t)(num))) : \ ((type *) malloc(sizeof(type) * (size_t)(num)))) +#ifndef ABC_MEMALIGN +# if defined(__arm__) +# define ABC_MEMALIGN 4 +# elif defined(__hppa__) +# define ABC_MEMALIGN 8 +# elif defined(__sparc__) +# define ABC_MEMALIGN 8 +//# else +//# warning unsupported platform +# endif +#endif // !ABC_MEMALIGN + +static inline size_t alignPad(size_t objsize) +{ +#ifdef ABC_MEMALIGN + if (objsize % ABC_MEMALIGN) + objsize += ABC_MEMALIGN - (objsize % ABC_MEMALIGN); +#endif + return objsize; +} + static inline int Abc_AbsInt( int a ) { return a < 0 ? -a : a; } static inline int Abc_MaxInt( int a, int b ) { return a > b ? a : b; } static inline int Abc_MinInt( int a, int b ) { return a < b ? a : b; } diff --git a/src/opt/rwt/rwtMan.c b/src/opt/rwt/rwtMan.c index d7597e0886..6a9024fb8b 100644 --- a/src/opt/rwt/rwtMan.c +++ b/src/opt/rwt/rwtMan.c @@ -104,7 +104,7 @@ clk = Abc_Clock(); p->pTable = ABC_ALLOC( Rwt_Node_t *, p->nFuncs ); memset( p->pTable, 0, sizeof(Rwt_Node_t *) * p->nFuncs ); // create the elementary nodes - p->pMmNode = Mem_FixedStart( sizeof(Rwt_Node_t) ); + p->pMmNode = Mem_FixedStart( alignPad(sizeof(Rwt_Node_t)) ); p->vForest = Vec_PtrAlloc( 100 ); Rwt_ManAddVar( p, 0x0000, fPrecompute ); // constant 0 Rwt_ManAddVar( p, 0xAAAA, fPrecompute ); // var A