[07/16] tcg: Return NULL temp for TCG_CALL_DUMMY_ARG
diff mbox

Message ID 20170621024831.26019-8-rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson June 21, 2017, 2:48 a.m. UTC
Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tcg/tcg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alex Bennée June 27, 2017, 8:47 a.m. UTC | #1
Richard Henderson <rth@twiddle.net> writes:

> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>  tcg/tcg.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tcg/tcg.h b/tcg/tcg.h
> index 3b35344..6c357e7 100644
> --- a/tcg/tcg.h
> +++ b/tcg/tcg.h
> @@ -730,7 +730,7 @@ extern bool parallel_cpus;
>
>  static inline TCGTemp *arg_temp(TCGArg a)
>  {
> -    return &tcg_ctx.temps[a];
> +    return a == TCG_CALL_DUMMY_ARG ? NULL : &tcg_ctx.temps[a];
>  }

It doesn't look like a lot of calls to arg_temp are able to deal with a
NULL return and may well immediately deref the value. Are we sure the
cases the TCG_CALL_DUMMY arg is involved are narrowly defined?

>
>  static inline void tcg_set_insn_param(int op_idx, int arg, TCGArg v)


--
Alex Bennée
Richard Henderson June 27, 2017, 4:36 p.m. UTC | #2
On 06/27/2017 01:47 AM, Alex Bennée wrote:
> 
> Richard Henderson <rth@twiddle.net> writes:
> 
>> Signed-off-by: Richard Henderson <rth@twiddle.net>
>> ---
>>   tcg/tcg.h | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tcg/tcg.h b/tcg/tcg.h
>> index 3b35344..6c357e7 100644
>> --- a/tcg/tcg.h
>> +++ b/tcg/tcg.h
>> @@ -730,7 +730,7 @@ extern bool parallel_cpus;
>>
>>   static inline TCGTemp *arg_temp(TCGArg a)
>>   {
>> -    return &tcg_ctx.temps[a];
>> +    return a == TCG_CALL_DUMMY_ARG ? NULL : &tcg_ctx.temps[a];
>>   }
> 
> It doesn't look like a lot of calls to arg_temp are able to deal with a
> NULL return and may well immediately deref the value. Are we sure the
> cases the TCG_CALL_DUMMY arg is involved are narrowly defined?

They only appear as arguments to a call opcode.


r~

Patch
diff mbox

diff --git a/tcg/tcg.h b/tcg/tcg.h
index 3b35344..6c357e7 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -730,7 +730,7 @@  extern bool parallel_cpus;
 
 static inline TCGTemp *arg_temp(TCGArg a)
 {
-    return &tcg_ctx.temps[a];
+    return a == TCG_CALL_DUMMY_ARG ? NULL : &tcg_ctx.temps[a];
 }
 
 static inline void tcg_set_insn_param(int op_idx, int arg, TCGArg v)