From 5066bebe95a5c1d13f10d7059d4b2541447d680b Mon Sep 17 00:00:00 2001 From: MaartenBrock Date: Tue, 4 Mar 2008 21:28:19 +0000 Subject: [PATCH] * src/*/ralloc.c: removed IS_OP_RUONLY macro * src/ds390/ralloc.c (packRegisters), * src/mcs51/ralloc.c (packRegisters), * src/z80/ralloc.c (packRegisters): applied fix for bug 1618050, thanks Robert Larice * support/regression/tests/bug1618050.c: new, added * support/regression/fwk/include/testfwk.h, * support/regression/tests/bug1838000.c: moved _AUTOMEM and _STATMEM to testfwk.h * src/SDCCsymt.h: fixed typo in DECLSPEC2TXT git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@5069 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 10 +++++++++ src/SDCCsymt.h | 4 ++-- src/avr/ralloc.c | 2 -- src/ds390/ralloc.c | 3 +-- src/hc08/ralloc.c | 2 -- src/mcs51/ralloc.c | 1 + src/pic/ralloc.c | 2 -- src/pic16/ralloc.c | 2 -- src/xa51/ralloc.c | 2 -- src/z80/ralloc.c | 5 ++--- support/regression/fwk/include/testfwk.h | 7 +++++++ support/regression/tests/bug1618050.c | 26 ++++++++++++++++++++++++ support/regression/tests/bug1838000.c | 7 ------- 13 files changed, 49 insertions(+), 24 deletions(-) create mode 100644 support/regression/tests/bug1618050.c diff --git a/ChangeLog b/ChangeLog index e11476d5..323fbf18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,16 @@ * src/SDCCutil.h: added getBuildDate() * src/SDCCmain.c (printVersionInfo), * src/SDCCglue.c (initialComments): use getBuildDate() instead of __DATE__ + * src/*/ralloc.c: removed IS_OP_RUONLY macro + * src/ds390/ralloc.c (packRegisters), + * src/mcs51/ralloc.c (packRegisters), + * src/z80/ralloc.c (packRegisters): applied fix for bug 1618050, thanks + Robert Larice + * support/regression/tests/bug1618050.c: new, added + * src/SDCCsymt.h: fixed typo in DECLSPEC2TXT + * support/regression/fwk/include/testfwk.h, + * support/regression/tests/bug1838000.c: moved _AUTOMEM and _STATMEM to + testfwk.h 2008-03-04 Raphael Neider diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h index 79230277..da91be01 100644 --- a/src/SDCCsymt.h +++ b/src/SDCCsymt.h @@ -217,7 +217,7 @@ typedef enum { DECLARATOR=1, SPECIFIER } SYM_LINK_CLASS; -#define DECLSPEC2TXT(select) (select==DECLARATOR?"DECLARATOR":select==SPECIFIER?"SPECIFIER":"UNKNOW") +#define DECLSPEC2TXT(select) (select==DECLARATOR?"DECLARATOR":select==SPECIFIER?"SPECIFIER":"UNKNOWN") typedef struct sym_link { @@ -505,7 +505,7 @@ extern sym_link *validateLink(sym_link *l, x->select.s.noun == V_SBIT )) #define IS_BITFIELD(x) (IS_SPEC(x) && (x->select.s.noun == V_BITFIELD)) #define IS_BITVAR(x) (IS_SPEC(x) && (x->select.s.noun == V_BITFIELD || \ - x->select.s.noun == V_BIT || \ + x->select.s.noun == V_BIT || \ x->select.s.noun == V_SBIT )) #define IS_BIT(x) (IS_SPEC(x) && (x->select.s.noun == V_BIT || \ x->select.s.noun == V_SBIT )) diff --git a/src/avr/ralloc.c b/src/avr/ralloc.c index 9f0ab65b..512edc4f 100644 --- a/src/avr/ralloc.c +++ b/src/avr/ralloc.c @@ -1829,8 +1829,6 @@ packRegsForAssign (iCode * ic, eBBlock * ebp) } -#define IS_OP_RUONLY(x) (x && IS_SYMOP(x) && OP_SYMBOL(x)->ruonly) - /*-----------------------------------------------------------------*/ /* packRegsForOneuse : - will reduce some registers for single Use */ diff --git a/src/ds390/ralloc.c b/src/ds390/ralloc.c index 3db3a848..f166a647 100644 --- a/src/ds390/ralloc.c +++ b/src/ds390/ralloc.c @@ -2475,8 +2475,6 @@ right: return change; } -#define IS_OP_RUONLY(x) (x && IS_SYMOP(x) && OP_SYMBOL(x)->ruonly) - /*-----------------------------------------------------------------*/ /* packRegsDPTRnuse - color live ranges that can go into extra DPTRS */ @@ -3069,6 +3067,7 @@ packRegisters (eBBlock ** ebpp, int blockno) IS_SYMOP (IC_RIGHT (ic)) && OP_SYMBOL (IC_RIGHT (ic))->remat && !IS_CAST_ICODE(OP_SYMBOL (IC_RIGHT (ic))->rematiCode) && + !isOperandGlobal(IC_RESULT(ic)) && /* due to bug 1618050 */ bitVectnBitsOn (OP_SYMBOL (IC_RESULT (ic))->defs) <= 1) { OP_SYMBOL (IC_RESULT (ic))->remat = diff --git a/src/hc08/ralloc.c b/src/hc08/ralloc.c index f109c275..bdbcda28 100644 --- a/src/hc08/ralloc.c +++ b/src/hc08/ralloc.c @@ -2277,8 +2277,6 @@ packRegsForSupport (iCode * ic, eBBlock * ebp) return changes; } -#define IS_OP_RUONLY(x) (x && IS_SYMOP(x) && OP_SYMBOL(x)->ruonly) - #if 0 /*-----------------------------------------------------------------*/ diff --git a/src/mcs51/ralloc.c b/src/mcs51/ralloc.c index 62fb84c5..2a627aad 100644 --- a/src/mcs51/ralloc.c +++ b/src/mcs51/ralloc.c @@ -3015,6 +3015,7 @@ packRegisters (eBBlock ** ebpp, int blockno) IS_SYMOP (IC_RIGHT (ic)) && OP_SYMBOL (IC_RIGHT (ic))->remat && !IS_CAST_ICODE(OP_SYMBOL (IC_RIGHT (ic))->rematiCode) && + !isOperandGlobal(IC_RESULT(ic)) && /* due to bug 1618050 */ bitVectnBitsOn (OP_SYMBOL (IC_RESULT (ic))->defs) <= 1) { OP_SYMBOL (IC_RESULT (ic))->remat = diff --git a/src/pic/ralloc.c b/src/pic/ralloc.c index d2c184c1..9b181ce6 100644 --- a/src/pic/ralloc.c +++ b/src/pic/ralloc.c @@ -3217,8 +3217,6 @@ right: return change; } -#define IS_OP_RUONLY(x) (x && IS_SYMOP(x) && OP_SYMBOL(x)->ruonly) - /*-----------------------------------------------------------------*/ /* packRegsForOneuse : - will reduce some registers for single Use */ diff --git a/src/pic16/ralloc.c b/src/pic16/ralloc.c index c79ccfdb..6bd0c35c 100644 --- a/src/pic16/ralloc.c +++ b/src/pic16/ralloc.c @@ -3411,8 +3411,6 @@ right: #endif -#define IS_OP_RUONLY(x) (x && IS_SYMOP(x) && OP_SYMBOL(x)->ruonly) - #ifndef NO_packRegsForOneuse /*-----------------------------------------------------------------*/ /* packRegsForOneuse : - will reduce some registers for single Use */ diff --git a/src/xa51/ralloc.c b/src/xa51/ralloc.c index ac0d124b..830a30f1 100644 --- a/src/xa51/ralloc.c +++ b/src/xa51/ralloc.c @@ -1609,8 +1609,6 @@ packRegsForSupport (iCode * ic, eBBlock * ebp) return change; } -#define IS_OP_RUONLY(x) (x && IS_SYMOP(x) && OP_SYMBOL(x)->ruonly) - /*-----------------------------------------------------------------*/ /* packRegsForOneuse : - will reduce some registers for single Use */ diff --git a/src/z80/ralloc.c b/src/z80/ralloc.c index 316063d7..fc3cfd1d 100644 --- a/src/z80/ralloc.c +++ b/src/z80/ralloc.c @@ -1978,8 +1978,6 @@ right: } #endif -#define IS_OP_RUONLY(x) (x && IS_SYMOP(x) && OP_SYMBOL(x)->ruonly) - /** Will reduce some registers for single use. */ static iCode * @@ -2978,9 +2976,10 @@ packRegisters (eBBlock * ebp) !POINTER_SET (ic) && IS_SYMOP (IC_RIGHT (ic)) && OP_SYMBOL (IC_RIGHT (ic))->remat && + !IS_CAST_ICODE(OP_SYMBOL (IC_RIGHT (ic))->rematiCode) && + !isOperandGlobal(IC_RESULT(ic)) && /* due to bug 1618050 */ bitVectnBitsOn (OP_SYMBOL (IC_RESULT (ic))->defs) <= 1) { - OP_SYMBOL (IC_RESULT (ic))->remat = OP_SYMBOL (IC_RIGHT (ic))->remat; OP_SYMBOL (IC_RESULT (ic))->rematiCode = diff --git a/support/regression/fwk/include/testfwk.h b/support/regression/fwk/include/testfwk.h index 81e82253..1e5d581b 100644 --- a/support/regression/fwk/include/testfwk.h +++ b/support/regression/fwk/include/testfwk.h @@ -11,6 +11,13 @@ void __printf(const char *szFormat, ...); #define LOG(_a) /* hollow log */ #endif +#ifdef SDCC + #include +#else + #define _AUTOMEM + #define _STATMEM +#endif + #if defined(PORT_HOST) || defined(SDCC_z80) || defined(SDCC_gbz80) # define data # define idata diff --git a/support/regression/tests/bug1618050.c b/support/regression/tests/bug1618050.c new file mode 100644 index 00000000..cd0d21b0 --- /dev/null +++ b/support/regression/tests/bug1618050.c @@ -0,0 +1,26 @@ +/** bug 1618050 + * global variable px in function buggy, is marked rematr.. + * and is erronously assumed to retain its value "x" across + * the function call to fiddle_px + */ + +#include + +_STATMEM char * data px; +_STATMEM char x[2] = {0,42}; + +void fiddle_px(_STATMEM char * unused) { + (volatile char) unused[0]; // shut up + px++; +} + +char buggy(void) { + px = x; + fiddle_px(x); + return *px; +} + +void +testBug(void) { + ASSERT(buggy() == 42); +} diff --git a/support/regression/tests/bug1838000.c b/support/regression/tests/bug1838000.c index eb54db93..5bafa2f1 100644 --- a/support/regression/tests/bug1838000.c +++ b/support/regression/tests/bug1838000.c @@ -4,13 +4,6 @@ #include -#ifdef SDCC - #include -#else - #define _AUTOMEM - #define _STATMEM -#endif - typedef struct { char b:1; } t; t glbl = { 0 }; t _STATMEM * gp = &glbl; -- 2.30.2