From 6694391b745f7ccc453bee83143e3528879f3b37 Mon Sep 17 00:00:00 2001 From: herman ten brugge Date: Sun, 3 Aug 2025 10:35:58 +0200 Subject: [PATCH] Update gcctestsuite I updated the tests/gcctestsuite.sh a bit. before: 3329 test(s) ok. 210 test(s) skipped. 168 test(s) failed. 28 test(s) exe failed. after: 3331 test(s) ok. 299 test(s) skipped. 79 test(s) failed. 26 test(s) exe failed. I found some small problems: include/tccdefs.h: Add alloca definition for i386 and x86_64 lib/alloca.S/lib/alloca-bt.S: align i386 alloca to 16 bytes. i386_gen.c vla code and gcc do the same. x86_64-gen.c: fix typo in comment --- include/tccdefs.h | 1 + lib/alloca-bt.S | 5 ++- lib/alloca.S | 5 ++- tests/gcctestsuite.sh | 85 +++++++++++++++++++++++++------------------ x86_64-gen.c | 2 +- 5 files changed, 57 insertions(+), 41 deletions(-) diff --git a/include/tccdefs.h b/include/tccdefs.h index bcde244b..eaf0c58c 100644 --- a/include/tccdefs.h +++ b/include/tccdefs.h @@ -310,6 +310,7 @@ __MAYBE_REDIR(void, free, (void*)) #if defined __i386__ || defined __x86_64__ __BOTH(void*, alloca, (__SIZE_TYPE__)) + void *alloca(__SIZE_TYPE__); #else __BUILTIN(void*, alloca, (__SIZE_TYPE__)) #endif diff --git a/lib/alloca-bt.S b/lib/alloca-bt.S index c1614886..d9738949 100644 --- a/lib/alloca-bt.S +++ b/lib/alloca-bt.S @@ -15,8 +15,9 @@ _(__bound_alloca): pop %edx pop %eax mov %eax, %ecx - add $3+1,%eax - and $-4,%eax + add $15+1,%eax + and $-16,%eax + sub $4,%eax jz p6 #ifdef _WIN32 diff --git a/lib/alloca.S b/lib/alloca.S index 6ebafd7c..0c37546e 100644 --- a/lib/alloca.S +++ b/lib/alloca.S @@ -16,8 +16,9 @@ _(__alloca): push %ebp mov %esp,%ebp mov 8(%ebp),%eax - add $3,%eax - and $-4,%eax + add $15,%eax + and $-16,%eax + sub $4,%eax #ifdef _WIN32 jmp .+16 #p2 p1: diff --git a/tests/gcctestsuite.sh b/tests/gcctestsuite.sh index b6f9ec21..9c19966f 100755 --- a/tests/gcctestsuite.sh +++ b/tests/gcctestsuite.sh @@ -68,9 +68,11 @@ nb_exe_failed="0" old_pwd="`pwd`" cd "$TESTSUITE_PATH" -skip_builtin="`grep "_builtin_" compile/*.c execute/*.c execute/ieee/*.c | cut -d ':' -f1 | cut -d '/' -f2 | sort -u `" -skip_ieee="`grep "_builtin_" execute/ieee/*.c | cut -d ':' -f1 | cut -d '/' -f3 | sort -u `" -skip_complex="`grep -i "_Complex" compile/*.c execute/*.c execute/ieee/*.c | cut -d ':' -f1 | cut -d '/' -f2 | sort -u `" +skip_builtin="`grep '_builtin_' compile/*.c execute/*.c execute/ieee/*.c | cut -d ':' -f1 | cut -d '/' -f2 | sort -u `" +skip_ieee="`grep '_builtin_' execute/ieee/*.c | cut -d ':' -f1 | cut -d '/' -f3 | sort -u `" +skip_complex="`grep -i '_Complex' compile/*.c execute/*.c execute/ieee/*.c | cut -d ':' -f1 | cut -d '/' -f2 | sort -u `" +skip_int128="`grep -Eiw '__int128_t|__uint128_t' compile/*.c execute/*.c execute/ieee/*.c | cut -d ':' -f1 | cut -d '/' -f2 | sort -u `" +skip_vector="`grep -Eiw 'vector|vector_size|__vector_size__' compile/*.c execute/*.c execute/ieee/*.c | cut -d ':' -f1 | cut -d '/' -f2 | sort -u `" skip_misc="20000120-2.c mipscop-1.c mipscop-2.c mipscop-3.c mipscop-4.c fp-cmp-4f.c fp-cmp-4l.c fp-cmp-8f.c fp-cmp-8l.c pr38016.c " @@ -78,21 +80,27 @@ cd "$old_pwd" for src in $TESTSUITE_PATH/compile/*.c ; do echo $TCC -o $RUNTIME_DIR/tst.o -c $src - $TCC -o $RUNTIME_DIR/tst.o -c $src >> tcc.fail 2>&1 - if [ "$?" = "0" ] ; then - result="PASS" - nb_ok=$(( $nb_ok + 1 )) + if $TCC -o $RUNTIME_DIR/tst.o -c $src 2>&1 | grep 'cannot use local functions' >/dev/null 2>&1 + then + result="SKIP" + nb_skipped=$(( $nb_skipped + 1 )) else - base=`basename "$src"` - skip_me="`echo $skip_builtin $skip_ieee $skip_complex $skip_misc | grep -w $base`" - - if [ -n "$skip_me" ] - then - result="SKIP" - nb_skipped=$(( $nb_skipped + 1 )) + $TCC -o $RUNTIME_DIR/tst.o -c $src >> tcc.fail 2>&1 + if [ "$?" = "0" ] ; then + result="PASS" + nb_ok=$(( $nb_ok + 1 )) else - result="FAIL" - nb_failed=$(( $nb_failed + 1 )) + base=`basename "$src"` + skip_me="`echo $skip_builtin $skip_ieee $skip_complex $skip_int128 $skip_misc $skip_vector | grep -w $base`" + + if [ -n "$skip_me" ] + then + result="SKIP" + nb_skipped=$(( $nb_skipped + 1 )) + else + result="FAIL" + nb_failed=$(( $nb_failed + 1 )) + fi fi fi echo "$result: $src" >> tcc.sum @@ -105,28 +113,33 @@ fi for src in $TESTSUITE_PATH/execute/*.c $TESTSUITE_PATH/execute/ieee/*.c ; do echo $TCC $src -o $RUNTIME_DIR/tst -lm - $TCC $src -o $RUNTIME_DIR/tst -lm >> tcc.fail 2>&1 - if [ "$?" = "0" ] ; then - result="PASS" - if $RUNTIME_DIR/tst >> tcc.fail 2>&1 - then - result="PASS" - nb_ok=$(( $nb_ok + 1 )) - else - result="FAILEXE" - nb_exe_failed=$(( $nb_exe_failed + 1 )) - fi + if $TCC $src -o $RUNTIME_DIR/tst -lm 2>&1 | grep 'cannot use local functions' >/dev/null 2>&1 + then + result="SKIP" + nb_skipped=$(( $nb_skipped + 1 )) else - base=`basename "$src"` - skip_me="`echo $skip_builtin $skip_ieee $skip_complex $skip_misc | grep -w $base`" - - if [ -n "$skip_me" ] - then - result="SKIP" - nb_skipped=$(( $nb_skipped + 1 )) + $TCC $src -o $RUNTIME_DIR/tst -lm >> tcc.fail 2>&1 + if [ "$?" = "0" ] ; then + if $RUNTIME_DIR/tst >> tcc.fail 2>&1 + then + result="PASS" + nb_ok=$(( $nb_ok + 1 )) + else + result="FAILEXE" + nb_exe_failed=$(( $nb_exe_failed + 1 )) + fi else - result="FAIL" - nb_failed=$(( $nb_failed + 1 )) + base=`basename "$src"` + skip_me="`echo $skip_builtin $skip_ieee $skip_complex $skip_int128 $skip_misc $skip_vector | grep -w $base`" + + if [ -n "$skip_me" ] + then + result="SKIP" + nb_skipped=$(( $nb_skipped + 1 )) + else + result="FAIL" + nb_failed=$(( $nb_failed + 1 )) + fi fi fi echo "$result: $src" >> tcc.sum diff --git a/x86_64-gen.c b/x86_64-gen.c index ce521141..ad70b45b 100644 --- a/x86_64-gen.c +++ b/x86_64-gen.c @@ -1503,7 +1503,7 @@ void gfunc_prolog(Sym *func_sym) gen_le32(seen_stack_size); /* movq %r11, -0x10(%rbp) */ o(0xf05d894c); - /* leaq $-192(%rbp), %r11 */ + /* leaq $-200(%rbp), %r11 */ o(0x9d8d4c); gen_le32(-176 - 24); /* movq %r11, -0x8(%rbp) */