qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] target/sh4: Emit insn_start for each insn in gUSA region
@ 2023-06-03 16:55 Richard Henderson
  2023-06-05 14:50 ` Philippe Mathieu-Daudé
  2023-06-05 15:01 ` Philippe Mathieu-Daudé
  0 siblings, 2 replies; 4+ messages in thread
From: Richard Henderson @ 2023-06-03 16:55 UTC (permalink / raw)
  To: qemu-devel; +Cc: ysato, philmd

Fixes an assert in tcg_gen_code that we don't accidentally
eliminate an insn_start during optimization.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---

Test case is tests/tcg/multiarch/testthread.c; the assert for
equality is new with

https://lore.kernel.org/qemu-devel/20230531040330.8950-26-richard.henderson@linaro.org/


r~
---
 target/sh4/translate.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/target/sh4/translate.c b/target/sh4/translate.c
index efd889d9d3..49c87d7a01 100644
--- a/target/sh4/translate.c
+++ b/target/sh4/translate.c
@@ -2144,9 +2144,7 @@ static void decode_gusa(DisasContext *ctx, CPUSH4State *env)
 
     /* The entire region has been translated.  */
     ctx->envflags &= ~TB_FLAG_GUSA_MASK;
-    ctx->base.pc_next = pc_end;
-    ctx->base.num_insns += max_insns - 1;
-    return;
+    goto done;
 
  fail:
     qemu_log_mask(LOG_UNIMP, "Unrecognized gUSA sequence %08x-%08x\n",
@@ -2163,8 +2161,19 @@ static void decode_gusa(DisasContext *ctx, CPUSH4State *env)
        purposes of accounting within the TB.  We might as well report the
        entire region consumed via ctx->base.pc_next so that it's immediately
        available in the disassembly dump.  */
+
+ done:
     ctx->base.pc_next = pc_end;
     ctx->base.num_insns += max_insns - 1;
+
+    /*
+     * Emit insn_start to cover each of the insns in the region.
+     * This matches an assert in tcg.c making sure that we have
+     * tb->icount * insn_start.
+     */
+    for (i = 1; i < max_insns; ++i) {
+        tcg_gen_insn_start(pc + i * 2, ctx->envflags);
+    }
 }
 #endif
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] target/sh4: Emit insn_start for each insn in gUSA region
  2023-06-03 16:55 [PATCH] target/sh4: Emit insn_start for each insn in gUSA region Richard Henderson
@ 2023-06-05 14:50 ` Philippe Mathieu-Daudé
  2023-06-05 15:01 ` Philippe Mathieu-Daudé
  1 sibling, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-05 14:50 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: ysato, Anton Johansson

On 3/6/23 18:55, Richard Henderson wrote:
> Fixes an assert in tcg_gen_code that we don't accidentally
> eliminate an insn_start during optimization.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> 
> Test case is tests/tcg/multiarch/testthread.c; the assert for
> equality is new with
> 
> https://lore.kernel.org/qemu-devel/20230531040330.8950-26-richard.henderson@linaro.org/

Cc'ing Anton.

> 
> 
> r~
> ---
>   target/sh4/translate.c | 15 ++++++++++++---
>   1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/target/sh4/translate.c b/target/sh4/translate.c
> index efd889d9d3..49c87d7a01 100644
> --- a/target/sh4/translate.c
> +++ b/target/sh4/translate.c
> @@ -2144,9 +2144,7 @@ static void decode_gusa(DisasContext *ctx, CPUSH4State *env)
>   
>       /* The entire region has been translated.  */
>       ctx->envflags &= ~TB_FLAG_GUSA_MASK;
> -    ctx->base.pc_next = pc_end;
> -    ctx->base.num_insns += max_insns - 1;
> -    return;
> +    goto done;
>   
>    fail:
>       qemu_log_mask(LOG_UNIMP, "Unrecognized gUSA sequence %08x-%08x\n",
> @@ -2163,8 +2161,19 @@ static void decode_gusa(DisasContext *ctx, CPUSH4State *env)
>          purposes of accounting within the TB.  We might as well report the
>          entire region consumed via ctx->base.pc_next so that it's immediately
>          available in the disassembly dump.  */
> +
> + done:
>       ctx->base.pc_next = pc_end;
>       ctx->base.num_insns += max_insns - 1;
> +
> +    /*
> +     * Emit insn_start to cover each of the insns in the region.
> +     * This matches an assert in tcg.c making sure that we have
> +     * tb->icount * insn_start.
> +     */
> +    for (i = 1; i < max_insns; ++i) {
> +        tcg_gen_insn_start(pc + i * 2, ctx->envflags);
> +    }
>   }
>   #endif
>   



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] target/sh4: Emit insn_start for each insn in gUSA region
  2023-06-03 16:55 [PATCH] target/sh4: Emit insn_start for each insn in gUSA region Richard Henderson
  2023-06-05 14:50 ` Philippe Mathieu-Daudé
@ 2023-06-05 15:01 ` Philippe Mathieu-Daudé
  2023-06-05 19:05   ` Richard Henderson
  1 sibling, 1 reply; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2023-06-05 15:01 UTC (permalink / raw)
  To: Richard Henderson, qemu-devel; +Cc: ysato

On 3/6/23 18:55, Richard Henderson wrote:
> Fixes an assert in tcg_gen_code that we don't accidentally
> eliminate an insn_start during optimization.
> 
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> 
> Test case is tests/tcg/multiarch/testthread.c; the assert for
> equality is new with
> 
> https://lore.kernel.org/qemu-devel/20230531040330.8950-26-richard.henderson@linaro.org/
> 
> 
> r~
> ---
>   target/sh4/translate.c | 15 ++++++++++++---
>   1 file changed, 12 insertions(+), 3 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] target/sh4: Emit insn_start for each insn in gUSA region
  2023-06-05 15:01 ` Philippe Mathieu-Daudé
@ 2023-06-05 19:05   ` Richard Henderson
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2023-06-05 19:05 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel; +Cc: ysato

On 6/5/23 08:01, Philippe Mathieu-Daudé wrote:
> On 3/6/23 18:55, Richard Henderson wrote:
>> Fixes an assert in tcg_gen_code that we don't accidentally
>> eliminate an insn_start during optimization.
>>
>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>> ---
>>
>> Test case is tests/tcg/multiarch/testthread.c; the assert for
>> equality is new with
>>
>> https://lore.kernel.org/qemu-devel/20230531040330.8950-26-richard.henderson@linaro.org/
>>
>>
>> r~
>> ---
>>   target/sh4/translate.c | 15 ++++++++++++---
>>   1 file changed, 12 insertions(+), 3 deletions(-)
> 
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> 

queued to tcg-next.

r~


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-05 19:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-03 16:55 [PATCH] target/sh4: Emit insn_start for each insn in gUSA region Richard Henderson
2023-06-05 14:50 ` Philippe Mathieu-Daudé
2023-06-05 15:01 ` Philippe Mathieu-Daudé
2023-06-05 19:05   ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).