[tree-ssa] RFC: Never gimplify ASM_EXPRs
Andrew Pinski
pinskia@physics.uc.edu
Thu Jun 5 15:44:00 GMT 2003
What about using the prefetch builtin?
That would solve the problems right?
Thanks,
Andrew Pinski
On Thursday, Jun 5, 2003, at 10:16 US/Eastern, Diego Novillo wrote:
>
> Jason,
>
> Andrew Haley found widespread breakage in libjava due to a
> miscompilation of boehm-gc.
>
>
> -----------------------------------------------------------------------
> ---------
> From: Andrew Haley <aph@redhat.com>
> Date: Fri, 16 May 2003 18:39:01 +0100
>
> Consider this code.
>
> void fubar (void *x)
> {
> __asm__ __volatile__ (" prefetch %0": :
> "m"(*(char *)(x)));
> }
>
> With gcc 3.3 you get
>
> fubar:
> #APP
> prefetch (%rdi)
> #NO_APP
> ret
>
> No problem there, everything is fine.
>
> With tree-ssa you get
>
> fubar:
> movzbl (%rdi), %edx
> movb %dl, -1(%rsp)
> #APP
> prefetch -1(%rsp)
> #NO_APP
> ret
>
> and this crashes the garbage collector. Because of this, no
> gcj
> programs even start.
>
> I can fix the problem with the simple patch appended, but it
> might be
> better to fix the compiler bug. Assuming, of course, that we
> agree it
> really is a bug.
>
> Andrew.
> -----------------------------------------------------------------------
> ---------
>
> The root of the problem is that the gimplifier is converting that
> ASM_EXPR into:
>
> fubar (void *x)
> {
> char *x.1;
> char T.2;
>
> x.1 = (char *)x;
> T.2 = *x.1;
> __asm__ __volatile__("prefetch %0"::"m" T.2);
> }
>
> I think this is a real bug and neither the gimplifier nor the
> optimizers
> should ever attempt to look into ASM_EXPRs. The same way we never even
> try to do anything with MD builtins.
>
> You could argue that we may be able to deal with ASMs, but I don't
> think
> we should. ASM_EXPRs and MD builtins are very low-level and we can't
> pretend to understand them at the tree level. I'm sure this bug will
> be
> very popular when trying to compile things like kernels.
>
> I'm testing a patch to completely remove processing of ASM_EXPRs from
> the gimplifier and tree optimizers. We are going to be marking
> ASM_EXPRs with TREE_NOT_GIMPLE.
>
> Ideas to fix the problem some other way?
>
>
> Diego.
>
>
>
More information about the Gcc
mailing list