qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: Laurent Vivier <laurent@vivier.eu>, qemu-devel@nongnu.org
Cc: Richard Henderson <richard.henderson@linaro.org>
Subject: Re: [PATCH] target/m68k: Remove unused variable in ABCD/SBCD memory opcodes
Date: Tue, 25 May 2021 10:32:13 +0200	[thread overview]
Message-ID: <482f902d-d06e-ed89-b609-50257bb931b2@amsat.org> (raw)
In-Reply-To: <ab11d44e-e0bd-d684-cadf-cbe641cb8be1@vivier.eu>

On 5/6/21 12:29 PM, Laurent Vivier wrote:
> Le 05/05/2021 à 18:43, Laurent Vivier a écrit :
>> Le 05/05/2021 à 18:03, Philippe Mathieu-Daudé a écrit :
>>> The ABCD / SBCD memory opcodes (introduced in commit fb5543d8200)
>>> don't use their "addr" variable.
>>>
>>> Remove the unused variable and pass a NULL argument instead to
>>> gen_ea_mode(). This fixes warnings generated when building with
>>> CFLAGS=-O3 (using GCC 10.2.1 20201125):
>>>
>>>   target/m68k/translate.c: In function ‘disas_sbcd_mem’:
>>>   target/m68k/translate.c:897:13: warning: ‘addr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>>>     897 |             delay_set_areg(s, reg0, tmp, false);
>>>         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>   target/m68k/translate.c:1866:21: note: ‘addr’ was declared here
>>>    1866 |     TCGv src, dest, addr;
>>>         |                     ^~~~
>>>
>>>   target/m68k/translate.c: In function ‘disas_abcd_mem’:
>>>   target/m68k/translate.c:897:13: warning: ‘addr’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>>>     897 |             delay_set_areg(s, reg0, tmp, false);
>>>         |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>   target/m68k/translate.c:1829:21: note: ‘addr’ was declared here
>>>    1829 |     TCGv src, dest, addr;
>>>         |                     ^~~~
>>>
>>
>> It's really strange because ABCD and SBCD support indirect predecrement (mode 4, "-(Ay),-(Ax)"), and
>> if you look into gen_ea_mode() &addr (addrp) is used with mode 4, it is initialized on EA_LOADU to
>> be reused on EA_STORE.
>>
>> The bug is somewhere else...
>>
> 
> I think I see what is the problem: as the mode is indirect pre-decrement, the register doesn't need
> to be updated and thus the addr is not needed.
> 
> But if we replace addrp by NULL, gen_lea_mode() will be called twice and the register will be
> decremented twice (on load and store, rather than only on load).

Ah OK I see. Well, I guess I'll let you have a look, you clearly have
better understanding :P Would it help if I fill a GitLab issue?


      reply	other threads:[~2021-05-25  8:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-05 16:03 [PATCH] target/m68k: Remove unused variable in ABCD/SBCD memory opcodes Philippe Mathieu-Daudé
2021-05-05 16:43 ` Laurent Vivier
2021-05-06 10:29   ` Laurent Vivier
2021-05-25  8:32     ` Philippe Mathieu-Daudé [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=482f902d-d06e-ed89-b609-50257bb931b2@amsat.org \
    --to=f4bug@amsat.org \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).