This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] RFC: Never gimplify ASM_EXPRs
- From: Diego Novillo <dnovillo at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: 05 Jun 2003 10:16:19 -0400
- Subject: [tree-ssa] RFC: Never gimplify ASM_EXPRs
- Organization: Red Hat Canada
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.