[m-dev.] diff: another fix for gcc 2.95

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Nov 13 11:53:28 AEDT 1999


Estimated hours taken: 0.5

runtime/mercury_engine.c:
	Add some code to call_engine_inner() to avoid
	over-optimization by gcc 2.95.	Previously I added such code
	to the BEGIN_MODULE() macro in runtime/mercury_goto.h,
	but call_engine_inner() does not use that macro, so
	we need to add it here too.

Workspace: /d-drive/home/hg/public/test_mercury/test_dirs/hg/mercury
Index: runtime/mercury_engine.c
===================================================================
RCS file: /home/staff/zs/imp/mercury/runtime/mercury_engine.c,v
retrieving revision 1.19
diff -u -d -r1.19 mercury_engine.c
--- runtime/mercury_engine.c	1999/10/18 15:46:52	1.19
+++ runtime/mercury_engine.c	1999/11/13 00:50:06
@@ -343,6 +343,24 @@
 	debugmsg1("in `call_engine_inner', locals at %p\n", (void *)locals);
 
 	/*
+	** We need to ensure that there is at least one
+	** real function call in call_engine_inner(), because
+	** otherwise gcc thinks that it doesn't need to
+	** restore the caller-save registers (such as
+	** the return address!) because it thinks call_engine_inner() is
+	** a leaf routine which doesn't call anything else,
+	** and so it thinks that they won't have been clobbered.
+	**
+	** This probably isn't necessary now that we exit from this function
+	** using longjmp(), but it doesn't do much harm, so I'm leaving it in.
+	**
+	** Also for gcc versions >= egcs1.1, we need to ensure that
+	** there is at least one jump to an unknown label.
+	*/
+	goto *dummy_identify_function(&&dummy_label);
+dummy_label:
+
+	/*
 	** Increment the number of times we've entered this
 	** engine from C, and mark the current context as being
 	** owned by this thread.
@@ -396,21 +414,6 @@
 	MR_ENGINE(this_context)->owner_thread = val;
 }
 #endif
-
-	/*
-	** We need to ensure that there is at least one
-	** real function call in call_engine_inner(), because
-	** otherwise gcc thinks that it doesn't need to
-	** restore the caller-save registers (such as
-	** the return address!) because it thinks call_engine_inner() is
-	** a leaf routine which doesn't call anything else,
-	** and so it thinks that they won't have been clobbered.
-	**
-	** This probably isn't necessary now that we exit from this function
-	** using longjmp(), but it doesn't do much harm, so I'm leaving it in.
-	*/
-
-	dummy_function_call();
 
 	debugmsg1("in label `engine_done', locals at %p\n", locals);
 

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list