|
From: <sv...@va...> - 2006-10-05 08:11:07
|
Author: tom
Date: 2006-10-05 09:11:06 +0100 (Thu, 05 Oct 2006)
New Revision: 6184
Log:
Mark the argument block as volatile to ensure the compiler actually
bothers to do the write to it (as it can't know that the inline
assembly is going to read from it).
Modified:
branches/AIX5/coregrind/m_syswrap/syswrap-ppc32-aix5.c
branches/AIX5/coregrind/m_syswrap/syswrap-ppc64-aix5.c
Modified: branches/AIX5/coregrind/m_syswrap/syswrap-ppc32-aix5.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syswrap-ppc32-aix5.c 2006-10-05 08:=
10:01 UTC (rev 6183)
+++ branches/AIX5/coregrind/m_syswrap/syswrap-ppc32-aix5.c 2006-10-05 08:=
11:06 UTC (rev 6184)
@@ -244,7 +244,7 @@
Word arg1 )
{
UWord* fdescr =3D (UWord*)f_NORETURN;
- UWord block[5];
+ volatile UWord block[5];
block[0] =3D fdescr[0]; /* nia */
block[1] =3D stack; /* r1 */
block[2] =3D fdescr[1]; /* r2 */
Modified: branches/AIX5/coregrind/m_syswrap/syswrap-ppc64-aix5.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- branches/AIX5/coregrind/m_syswrap/syswrap-ppc64-aix5.c 2006-10-05 08:=
10:01 UTC (rev 6183)
+++ branches/AIX5/coregrind/m_syswrap/syswrap-ppc64-aix5.c 2006-10-05 08:=
11:06 UTC (rev 6184)
@@ -244,7 +244,7 @@
Word arg1 )
{
UWord* fdescr =3D (UWord*)f_NORETURN;
- UWord block[5];
+ volatile UWord block[5];
block[0] =3D fdescr[0]; /* nia */
block[1] =3D stack; /* r1 */
block[2] =3D fdescr[1]; /* r2 */
|
|
From: Nicholas N. <nj...@cs...> - 2006-10-05 08:33:14
|
On Thu, 5 Oct 2006 sv...@va... wrote: > Author: tom > Date: 2006-10-05 09:11:06 +0100 (Thu, 05 Oct 2006) > New Revision: 6184 > > Log: > Mark the argument block as volatile to ensure the compiler actually > bothers to do the write to it (as it can't know that the inline > assembly is going to read from it). Can you add a comment to the code about this? And for your next commit? Thanks :) Nick |
|
From: Tom H. <to...@co...> - 2006-10-05 08:38:14
|
In message <Pin...@mu...>
Nicholas Nethercote <nj...@cs...> wrote:
> On Thu, 5 Oct 2006 sv...@va... wrote:
>
>> Author: tom
>> Date: 2006-10-05 09:11:06 +0100 (Thu, 05 Oct 2006)
>> New Revision: 6184
>>
>> Log:
>> Mark the argument block as volatile to ensure the compiler actually
>> bothers to do the write to it (as it can't know that the inline
>> assembly is going to read from it).
>
> Can you add a comment to the code about this? And for your next commit?
That's a bit of a quick hack really - I'm not sure why we're bothering
to create that block at all instead of just asking gcc to bind the
variables to the assembly directly. Perhaps Julian can comment?
Tom
--
Tom Hughes (to...@co...)
http://www.compton.nu/
|
|
From: Julian S. <js...@ac...> - 2006-10-05 10:07:33
|
> >> Log: > >> Mark the argument block as volatile to ensure the compiler actually > >> bothers to do the write to it (as it can't know that the inline > >> assembly is going to read from it). > > > > Can you add a comment to the code about this? And for your next commit? > > That's a bit of a quick hack really - I'm not sure why we're bothering > to create that block at all instead of just asking gcc to bind the > variables to the assembly directly. Perhaps Julian can comment? General lameness/conservatism on my part, mostly. Over the years I've sometimes found it difficult to write inline assembly which works reliably over different gcc versions, particularly for doing stuff like syscalls in which there are a lot of register constraints to get right. I don't think it helped that I never really felt confident I understood the finer details of the gcc inline-assembly constraint syntax. Nor did I entirely believe that all versions of gcc implement it properly :) So, more recently I've taken to parking all the relevant info in a block of words in C and passing a pointer to it into the code fragment, which is simple at least. It is maybe not the best solution,I agree. > On Thursday 05 October 2006 09:48, Dirk Mueller wrote: > > Hmm, this might work, but I'm not 100% sure it is correct. why are the > fields besides [0] not listed in the asm constraints? Then it would tell > the compiler what is going on. My understanding of 'volatile' is it tells the compiler not to change the number of memory references to the object. Harbison & Steele says: The 'volatile' type specifier informs the ISO C implementation that certain objects can have their values altered in ways not under control of the implementation. That is, any object (strictly speaking, any lvalue expression) of a 'volatile'-qualified type should not participate in optimizations that would increase, decrease, or delay any references to, or modifications of, the object. [ .. followed by a definition of sequence points in C .. ] Tom's fix seems like a fairly safe solution to me. Dirk, was there some other problem you thought could happen? J |
|
From: Dirk M. <dm...@gm...> - 2006-10-05 08:48:27
|
On Thursday, 5. October 2006 10:11, sv...@va... wrote: > Mark the argument block as volatile to ensure the compiler actually > bothers to do the write to it (as it can't know that the inline > assembly is going to read from it). Hmm, this might work, but I'm not 100% sure it is correct. why are the fields besides [0] not listed in the asm constraints? Then it would tell the compiler what is going on. Dirk |