|
From: Carl L. <ce...@us...> - 2023-04-19 18:31:31
|
On Wed, 2023-04-19 at 08:08 -0700, John Reiser wrote:
> >
<snip>
> On 4/18/23 12:53, Carl Love via Valgrind-developers wrote:
>
> At the lowest level, the problem is that a statement such as
> __asm__ __volatile__ ("ori 21,21,21");
Yes, that is the issue because it is using registers that the compiler
is not aware of.
> in the PAD_ORI macro of none/tests/ppc64/isa_3_1_helpers.h
> is incomplete because it does not specify the CLOBBERS portion of
> __asm__.
> [See
> https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html
> e= ]
> Here is a more-complete statement that tells the compiler
> that the __asm__ scribbles on register 21:
> __asm__ __volatile__ ("ori 21,21,21"
> : /* empty: no outputs from asm to C */
> : /* empty: no inputs from C to asm */
> : "21" /* clobbers register 21 */
> );
>
I wasn't aware of the full specification on the asm command. This is
really helpful.
> Omitting the CLOBBERS is surprising because other __asm__ in the same
> file
> do use it, such as:
> __asm__ __volatile__ ("mtcr %0" : : "b"(_arg) : ALLCR );
>
> If the CLOBBERS are specified, the the compiler automatically saves
> and
> restores the clobbered registers, if required because "callee saved"
> by the
> global usage convention.
Yup, I tried removing the SAVE_REG and RESTORE_REG macros I added and
updated the PAD_ORI macro instead. This works as you said. It does
have the added advantage of removing the modification of the fetched
register by the instructions under test which my save/restore registers
macro didn't do.
I have created an additional patch to change the fix for the tests
using your approach which I will commit shortly.
Thanks for the help.
Carl
|