On Mon, Nov 2, 2020 at 5:52 PM Chen Qun <kuhn.chen...@huawei.com> wrote:
>
> The compiler cannot determine whether the return values of the 
> xtensa_operand_is_register(isa, opc, opnd)
>  and xtensa_operand_is_visible(isa, opc, opnd) functions are the same.

It doesn't have to because 1) they definitely are not the same, but
2) it doesn't matter.

> So,it assumes that 'rf' is not assigned, but it's used.

The assumption is wrong. rf is used under the 'if (register_file)'
condition and register_file is initialized to NULL and then set
to something non-NULL based on the value of rf here:

958             if (xtensa_operand_is_register(isa, opc, opnd)) {
959                 rf = xtensa_operand_regfile(isa, opc, opnd);
960                 register_file = dc->config->regfile[rf];

> The compiler showed warning:
> target/xtensa/translate.c: In function ‘disas_xtensa_insn’:
> target/xtensa/translate.c:985:43: warning: ‘rf’ may be used uninitialized in 
> this function [-Wmaybe-uninitialized]
>   985 |                     arg[vopnd].num_bits = 
> xtensa_regfile_num_bits(isa, rf);
>       |                                           
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Add a default value for 'rf' to prevented the warning.

I don't see it doing default build with gcc 8.3. But then I don't see
-Wmaybe-uninitialized in the compiler command line either.

> Reported-by: Euler Robot <euler.ro...@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chen...@huawei.com>
> ---
> Cc: Max Filippov <jcmvb...@gmail.com>
> ---
>  target/xtensa/translate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c
> index 944a157747..eea851bbe7 100644
> --- a/target/xtensa/translate.c
> +++ b/target/xtensa/translate.c
> @@ -953,7 +953,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, 
> DisasContext *dc)
>
>          for (opnd = vopnd = 0; opnd < opnds; ++opnd) {
>              void **register_file = NULL;
> -            xtensa_regfile rf;
> +            xtensa_regfile rf = -1;

Please use XTENSA_UNDEFINED instead if you still think this
is worth changing.

-- 
Thanks.
-- Max

Reply via email to