From: Ben S. <pow...@16...> - 2014-12-01 14:37:32
|
Philipp, I find a bug, that sometimes a longlong variable is failed to be spilt, for example, #pragma std_sdcc99 long long x, y; void test_func(void) { x = y; } ; ----------------------------------------- ; function test_func ; ----------------------------------------- _test_func: ; a.c: 6: x = y; ld a, _y+7 ld (0x08, sp), a ld a, _y+6 ld (0x07, sp), a ld a, _y+5 ld (0x06, sp), a ld a, _y+4 ldw y, _y+2 ldw x, _y+0 push a ld a, (0x09, sp) ld _x+7, a ld a, (0x08, sp) ld _x+6, a ld a, (0x07, sp) ld _x+5, a pop a ld _x+4, a ldw _x+2, y ldw _x+0, x ret It seems a temporary variable should be spilt but actually not. Ben |
From: Ben S. <pow...@16...> - 2014-12-01 14:42:14
|
To fix that, I add 2 lines between line 479 - 480 of stm8/ralloc.c, D (D_ALLOC, ("serialRegAssign: in loop on result %p\n", sym)); // added be Ben if (!sym->isspilt) sym->usl.spillLoc = NULL; // end Ben if (sym->isspilt && sym->usl.spillLoc) // todo: Remove once remat is supported! { sym->usl.spillLoc->allocreq--; sym->isspilt = FALSE; } Is that right? I do see this way works. 在2014年12月01 22时37分,"pow...@16..."<pow...@16...>写道: Philipp, I find a bug, that sometimes a longlong variable is failed to be spilt, for example, #pragma std_sdcc99 long long x, y; void test_func(void) { x = y; } ; ----------------------------------------- ; function test_func ; ----------------------------------------- _test_func: ; a.c: 6: x = y; ld a, _y+7 ld (0x08, sp), a ld a, _y+6 ld (0x07, sp), a ld a, _y+5 ld (0x06, sp), a ld a, _y+4 ldw y, _y+2 ldw x, _y+0 push a ld a, (0x09, sp) ld _x+7, a ld a, (0x08, sp) ld _x+6, a ld a, (0x07, sp) ld _x+5, a pop a ld _x+4, a ldw _x+2, y ldw _x+0, x ret It seems a temporary variable should be spilt but actually not. Ben |
From: Ben S. <pow...@16...> - 2014-12-01 14:44:41
|
This is the reason of bug #2308. 在2014年12月01 22时42分,"pow...@16..."<pow...@16...>写道: To fix that, I add 2 lines between line 479 - 480 of stm8/ralloc.c, D (D_ALLOC, ("serialRegAssign: in loop on result %p\n", sym)); // added be Ben if (!sym->isspilt) sym->usl.spillLoc = NULL; // end Ben if (sym->isspilt && sym->usl.spillLoc) // todo: Remove once remat is supported! { sym->usl.spillLoc->allocreq--; sym->isspilt = FALSE; } Is that right? I do see this way works. 在2014年12月01 22时37分,"pow...@16..."<pow...@16...>写道: Philipp, I find a bug, that sometimes a longlong variable is failed to be spilt, for example, #pragma std_sdcc99 long long x, y; void test_func(void) { x = y; } ; ----------------------------------------- ; function test_func ; ----------------------------------------- _test_func: ; a.c: 6: x = y; ld a, _y+7 ld (0x08, sp), a ld a, _y+6 ld (0x07, sp), a ld a, _y+5 ld (0x06, sp), a ld a, _y+4 ldw y, _y+2 ldw x, _y+0 push a ld a, (0x09, sp) ld _x+7, a ld a, (0x08, sp) ld _x+6, a ld a, (0x07, sp) ld _x+5, a pop a ld _x+4, a ldw _x+2, y ldw _x+0, x ret It seems a temporary variable should be spilt but actually not. Ben |
From: Philipp K. K. <pk...@sp...> - 2014-12-02 08:19:18
Attachments:
signature.asc
|
On 01.12.2014 15:44, Ben Shi wrote: > > This is the reason of bug #2308. I fixed the spill location issue in #9121, but #2308 is still there Philipp |
From: Ben S. <pow...@16...> - 2014-12-02 09:24:47
|
What is your error? Still invaild instructions or others? By my fix, the invalid instructions are elminated, but mul of longlong fails, since the _mullonglong.c assume little endian, but actually stm8 is big. Ben 在2014年12月02 16时19分,"Philipp Klaus Krause"<pk...@sp...>写道: On 01.12.2014 15:44, Ben Shi wrote: > > This is the reason of bug #2308. I fixed the spill location issue in #9121, but #2308 is still there Philipp |
From: Philipp K. K. <pk...@sp...> - 2014-12-02 09:35:00
Attachments:
signature.asc
|
On 02.12.2014 10:24, Ben Shi wrote: > What is your error? Still invaild instructions or others? > > By my fix, the invalid instructions are elminated, but mul of longlong > fails, since the _mullonglong.c assume little endian, but actually stm8 > is big. > > Ben The invalid instruction is gone. But multiplication and two other tests still fail. Philipp |
From: Ben S. <pow...@16...> - 2014-12-02 09:50:49
|
Philipp, Can you try to make the simulator's stack more larger? At my side, only mullonglong fails, others issues are fixed by Index: sim/ucsim/stm8.src/stm8.cc =================================================================== --- sim/ucsim/stm8.src/stm8.cc(revision 9120) +++ sim/ucsim/stm8.src/stm8.cc(working copy) @@ -90,13 +90,12 @@ { cl_uc::reset(); - regs.SP = 0x7ff; + regs.SP = 0x17ff; regs.A = 0; regs.X = 0; regs.Y = 0; regs.CC = 0x00; regs.VECTOR = 1; } Ben 在2014年12月02 17时34分,"Philipp Klaus Krause"<pk...@sp...>写道: On 02.12.2014 10:24, Ben Shi wrote: > What is your error? Still invaild instructions or others? > > By my fix, the invalid instructions are elminated, but mul of longlong > fails, since the _mullonglong.c assume little endian, but actually stm8 > is big. > > Ben The invalid instruction is gone. But multiplication and two other tests still fail. Philipp |
From: Philipp K. K. <pk...@sp...> - 2014-12-02 10:15:26
Attachments:
signature.asc
|
On 02.12.2014 10:50, Ben Shi wrote: > Philipp, > > Can you try to make the simulator's stack more larger? > > At my side, only mullonglong fails, others issues are fixed by I can't reproduce the other two now (they were ASSERT (x + y == (42ll << 23) + 42); and ASSERT (x - y == (42ll << 23) - 42);). Probably just some mistake on my side. With more RAM simulated, we might be able to enable some tests currently disabled for stm8 due to lack of RAM (they are the ones also disabled for gbz80, which doesn't have much RAM, either). Philipp |
From: Philipp K. K. <pk...@sp...> - 2014-12-01 19:19:11
Attachments:
signature.asc
|
On 01.12.2014 15:42, Ben Shi wrote: > To fix that, > > I add 2 lines between line 479 - 480 of stm8/ralloc.c, > > > D (D_ALLOC, ("serialRegAssign: in loop on result %p\n", sym)); > > > // added be Ben > > if (!sym->isspilt) > > sym->usl.spillLoc = NULL; > > // end Ben > > > if (sym->isspilt && sym->usl.spillLoc) // todo: Remove once > remat is supported! > > { > > sym->usl.spillLoc->allocreq--; > > sym->isspilt = FALSE; > > } > > > Is that right? I do see this way works. But why does the symbol already have a spill location? Even if I add sym->usl.spillLoc = 0 in newSymbol() in SDCCsymt.c, usl.spillLoc is nonzero when we enter spillThis() the first time for the iTemp in your example. I checked every location that writes usl.spillLoc (1 in SDCCptropt.c, 2 in stm8/ralloc.c. None of them applies to the iTemp). Maybe there is a deeper issue here? Something sets usl.spillLoc to a nonzero value, but I can't see what it is. Philipp |
From: Ben S. <pow...@16...> - 2014-12-02 03:37:43
|
I find that SDCCcse.c & SDCCicode.c would set usl.spillLoc, for example, unsigned long long x, xy; unsigned long w, yrt; void ss(void) { char ww[256]; x = xy; w = yrt; } iTemp0.usl.spillLoc is set to pointed to _xy, and iTemp1.usl.spillLoc is set to pointed to _yrt. I can not understand its intention, but I can add code to stm8 back end to handle this fake spillage. (at least for stm8 it is fake ) Ben 在2014年12月02 03时18分,"Philipp Klaus Krause"<pk...@sp...>写道: On 01.12.2014 15:42, Ben Shi wrote: > To fix that, > > I add 2 lines between line 479 - 480 of stm8/ralloc.c, > > > D (D_ALLOC, ("serialRegAssign: in loop on result %p\n", sym)); > > > // added be Ben > > if (!sym->isspilt) > > sym->usl.spillLoc = NULL; > > // end Ben > > > if (sym->isspilt && sym->usl.spillLoc) // todo: Remove once > remat is supported! > > { > > sym->usl.spillLoc->allocreq--; > > sym->isspilt = FALSE; > > } > > > Is that right? I do see this way works. But why does the symbol already have a spill location? Even if I add sym->usl.spillLoc = 0 in newSymbol() in SDCCsymt.c, usl.spillLoc is nonzero when we enter spillThis() the first time for the iTemp in your example. I checked every location that writes usl.spillLoc (1 in SDCCptropt.c, 2 in stm8/ralloc.c. None of them applies to the iTemp). Maybe there is a deeper issue here? Something sets usl.spillLoc to a nonzero value, but I can't see what it is. Philipp |
From: Philipp K. K. <pk...@sp...> - 2014-12-01 17:18:39
Attachments:
signature.asc
|
On 01.12.2014 15:37, Ben Shi wrote: > Philipp, > > I find a bug, that sometimes a longlong variable is failed to be spilt, > for example, > > #pragma std_sdcc99 > > long long x, y; > > > void test_func(void) > > { > > x = y; > > } I don't see what the problem is here. Philipp |
From: Philipp K. K. <pk...@sp...> - 2014-12-01 17:35:36
Attachments:
signature.asc
|
On 01.12.2014 15:37, Ben Shi wrote: > Philipp, > > I find a bug, that sometimes a longlong variable is failed to be spilt, > for example, > > #pragma std_sdcc99 > > long long x, y; > > > void test_func(void) > > { > > x = y; > > } > On the second look I see the issue: 3 bytes are spilt, but the stack pointer is not adjusted to create sufficient space for the spilt variable. Philipp |
From: Philipp K. K. <pk...@sp...> - 2014-12-01 18:31:16
Attachments:
signature.asc
|
On 01.12.2014 15:37, Ben Shi wrote: > #pragma std_sdcc99 > > long long x, y; > > > void test_func(void) > > { > > x = y; > > } > When using --max-allocs-per-node 1 the issue can be reproduceed even with int and long (not char though). Philipp |
From: Philipp K. K. <pk...@sp...> - 2014-12-02 06:30:33
Attachments:
signature.asc
|
On 02.12.2014 04:37, Ben Shi wrote: > I find that SDCCcse.c & SDCCicode.c would set usl.spillLoc […} Can you point me to the lines in SDCCcse.c and SDCCicode.c? Using grep spillLoc src/*.c I find only uses of spillLoc, but no assignments to it. Philipp |
From: Ben S. <pow...@16...> - 2014-12-02 06:45:00
|
There is a macro defined in DSCCicode.h, SDCCicode.h:#define SPIL_LOC(op) validateOpType(op, "SPIL_LOC", #op, SYMBOL, __FILE__, __LINE__)->svt.symOperand->usl.spillLoc and there are some places modify it via this macro. ccoredeMac-mini:src ccore$ grep SPIL_LOC * -r SDCCcse.c: ((!SPIL_LOC (IC_RIGHT (cdp->diCode)) && SPIL_LOC (IC_RESULT (cdp->diCode))) || SDCCcse.c: (SPIL_LOC (IC_RESULT (cdp->diCode)) && SPIL_LOC (IC_RESULT (cdp->diCode)) == SPIL_LOC (IC_RIGHT (cdp->diCode))))) SDCCcse.c: !SPIL_LOC (IC_RIGHT (ic))) SDCCcse.c: SPIL_LOC (IC_RIGHT (ic)) = IC_RESULT (ic)->operand.symOperand; SDCCcse.c: !SPIL_LOC(IC_RESULT(ic))) SDCCcse.c: SPIL_LOC (IC_RESULT (ic)) = IC_RIGHT (ic)->operand.symOperand; SDCCcse.c: if (!SPIL_LOC (IC_RIGHT (ic)) && SDCCcse.c: SPIL_LOC (IC_RIGHT (ic)) = SPIL_LOC (IC_RESULT (ic)); SDCCcse.c: !SPIL_LOC(IC_RESULT(ic))) SDCCcse.c: SPIL_LOC (IC_RESULT (ic)) = SPIL_LOC (IC_RIGHT (ic)); SDCCcse.c: SPIL_LOC (IC_RESULT (ic)) = NULL; SDCCicode.c: if (IN_STACK (etype) || OP_SYMBOL (op)->onStack || (SPIL_LOC (op) && SPIL_LOC (op)->onStack)) SDCCicode.c: SPIL_LOC (sym->reqv) = sym; SDCCicode.c: SPIL_LOC (newRight) = sym; SDCCicode.c: SPIL_LOC (sym->reqv) = sym; Ben 在2014年12月02 14时30分,"Philipp Klaus Krause"<pk...@sp...>写道: On 02.12.2014 04:37, Ben Shi wrote: > I find that SDCCcse.c & SDCCicode.c would set usl.spillLoc […} Can you point me to the lines in SDCCcse.c and SDCCicode.c? Using grep spillLoc src/*.c I find only uses of spillLoc, but no assignments to it. Philipp |
From: Erik P. <epe...@iv...> - 2014-12-02 06:50:14
|
On Tue, 2 Dec 2014, Philipp Klaus Krause wrote: > On 02.12.2014 04:37, Ben Shi wrote: >> I find that SDCCcse.c & SDCCicode.c would set usl.spillLoc [?} > > Can you point me to the lines in SDCCcse.c and SDCCicode.c? > Using > > grep spillLoc src/*.c > > I find only uses of spillLoc, but no assignments to it. > > Philipp Also grep for the macro SPIL_LOC Erik |