[m-rev.] for review: work around GCC bug

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Nov 22 03:51:47 AEDT 2002


On 22-Nov-2002, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> 
> Fix another occurrence of the GCC "fixed or forbidden register was spilled"
> bug, this time caused by foreign types.
> 
> runtime/mercury_heap.h:
> 	In the code to copy, box or unbox foreign type arguments of
> 	a foreign_proc, use MR_memcpy rather than direct structure
> 	assignment on platforms where the GCC bug occurs.

The log message doesn't correspond with the code -- the code uses
MR_memcpy() on all platforms.

Probably it would be better to do what the log message says.

> Index: runtime/mercury_reg_workarounds.h
...
> +/*
> +** This macro defines a safe way to perform assignment between
> +** structures. The obvious way can cause some versions of
> +** gcc to abort on x86 processors with the message
> +** "fixed or forbidden register was spilled."
> +*/
> +
> +#ifdef MR_CANNOT_USE_STRUCTURE_ASSIGNMENT
> +
> +#define MR_assign_structure(dest, src) \
> +		MR_memcpy((void *) &(dest), (void *) &(src), sizeof((dest)))
> +
> +#else /* !MR_CANNOT_USE_STRUCTURE_ASSIGNMENT */
> +
> +#define MR_assign_structure(dest, src)	((dest) = (src))
> +
> +#endif /* !MR_CANNOT_USE_STRUCTURE_ASSIGNMENT */

The #defines should be indented two spaces.

The casts to `(void *)' are not be needed, I'm pretty sure.

> +++ tests/valid/reg_bug.m	21 Nov 2002 15:49:31 -0000
> @@ -0,0 +1,21 @@
> +% Add a test case for yet another instance of the
> +% GCC 
> +:- module reg_bug.

The comment there is incomplete.

Otherwise that looks fine.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list