This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] ALIAS_SET_MEMORY_BARRIER for s390 and sparc (was Re: fix libgomp miscompilation on ppc64)
On Tue, Jan 31, 2006 at 10:46:40AM +0100, Richard Guenther wrote:
> On 1/31/06, Mark Mitchell <mark@codesourcery.com> wrote:
> > Jakub Jelinek wrote:
> >
> > > Yes, since libstdc++-v3 was not using the __sync_* builtins internally
> > > in GCC 4.0.x and earlier, but used inline assembly instead for the atomic
> > > stuff. We only saw the bug in libgomp so far, so it is possible in
> > > libstdc++-v3 we are just lucky enough to not expose it. Though it is
> > > unclear if GCC 4.1's libstdc++-v3 has been tested with all the compile
> > > flags combinations people will be actually using.
> >
> > OK, go ahead and apply the patch.
>
> Done.
ALIAS_SET_MEMORY_BARRIER needs to be set in s390/sparc backends too
when emulating QI/HImode atomics using SImode compare and swap.
Is the s390 part ok for trunk/4.1?
I'll commit the sparc part to trunk together with s390 (if approved),
4.1 has no compare and swap support in sparc.
2006-01-31 Jakub Jelinek <jakub@redhat.com>
* config/s390/s390.c (init_alignment_context): Set
ALIAS_SET_MEMORY_BARRIER on the MEM.
* config/sparc/sparc.c (sparc_expand_compare_and_swap_12): Likewise.
--- gcc/config/s390/s390.c.jj 2006-01-28 09:54:03.000000000 +0100
+++ gcc/config/s390/s390.c 2006-01-28 10:29:03.000000000 +0100
@@ -4030,6 +4030,7 @@ init_alignment_context (struct alignment
/* Generate MEM. */
ac->memsi = gen_rtx_MEM (SImode, align);
MEM_VOLATILE_P (ac->memsi) = MEM_VOLATILE_P (mem);
+ set_mem_alias_set (ac->memsi, ALIAS_SET_MEMORY_BARRIER);
set_mem_align (ac->memsi, GET_MODE_BITSIZE (SImode));
/* Calculate shiftcount. */
--- gcc/config/sparc/sparc.c.jj 2006-01-28 09:54:03.000000000 +0100
+++ gcc/config/sparc/sparc.c 2006-01-28 10:29:46.000000000 +0100
@@ -8734,6 +8734,7 @@ sparc_expand_compare_and_swap_12 (rtx re
gen_rtx_AND (SImode, addr1, GEN_INT (3))));
memsi = gen_rtx_MEM (SImode, addr);
+ set_mem_alias_set (memsi, ALIAS_SET_MEMORY_BARRIER);
MEM_VOLATILE_P (memsi) = MEM_VOLATILE_P (mem);
val = force_reg (SImode, memsi);
Jakub