Patchwork tcg: mark local temps as MEM in dead_temp()

login
register
mail settings
Submitter Aurelien Jarno
Date Nov. 24, 2012, 10:58 a.m.
Message ID <1353754694-18712-1-git-send-email-aurelien@aurel32.net>
Download mbox | patch
Permalink /patch/201455/
State New
Headers show

Comments

Aurelien Jarno - Nov. 24, 2012, 10:58 a.m.
In dead_temp, local temps should always be marked as back to memory,
even if they have not been allocated (i.e. they are discared before
cross a basic block).

It fixes the following assertion in target-xtensa:

    qemu-system-xtensa: tcg/tcg.c:1665: temp_save: Assertion `s->temps[temp].val_type == 2 || s->temps[temp].fixed_reg' failed.
    Aborted

Reported-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
---
 tcg/tcg.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Max Filippov - Nov. 24, 2012, 11:28 a.m.
On Sat, Nov 24, 2012 at 2:58 PM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> In dead_temp, local temps should always be marked as back to memory,
> even if they have not been allocated (i.e. they are discared before
> cross a basic block).
>
> It fixes the following assertion in target-xtensa:
>
>     qemu-system-xtensa: tcg/tcg.c:1665: temp_save: Assertion `s->temps[temp].val_type == 2 || s->temps[temp].fixed_reg' failed.
>     Aborted
>
> Reported-by: Max Filippov <jcmvbkbc@gmail.com>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

Tested-by: Max Filippov <jcmvbkbc@gmail.com>
Aurelien Jarno - Nov. 24, 2012, 12:26 p.m.
On Sat, Nov 24, 2012 at 02:28:15PM +0300, Max Filippov wrote:
> On Sat, Nov 24, 2012 at 2:58 PM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> > In dead_temp, local temps should always be marked as back to memory,
> > even if they have not been allocated (i.e. they are discared before
> > cross a basic block).
> >
> > It fixes the following assertion in target-xtensa:
> >
> >     qemu-system-xtensa: tcg/tcg.c:1665: temp_save: Assertion `s->temps[temp].val_type == 2 || s->temps[temp].fixed_reg' failed.
> >     Aborted
> >
> > Reported-by: Max Filippov <jcmvbkbc@gmail.com>
> > Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> 
> Tested-by: Max Filippov <jcmvbkbc@gmail.com>
> 

Thanks for the test, I have applied the patch.

Patch

diff --git a/tcg/tcg.c b/tcg/tcg.c
index 4f75696..cb193f2 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -1615,7 +1615,7 @@  static inline void temp_dead(TCGContext *s, int temp)
         if (ts->val_type == TEMP_VAL_REG) {
             s->reg_to_temp[ts->reg] = -1;
         }
-        if (temp < s->nb_globals || (ts->temp_local && ts->mem_allocated)) {
+        if (temp < s->nb_globals || ts->temp_local) {
             ts->val_type = TEMP_VAL_MEM;
         } else {
             ts->val_type = TEMP_VAL_DEAD;