[m-rev.] for review: function trailing and aligned addresses

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Jan 18 14:29:45 AEDT 2008

Mark had a similar problem with G12's trail module a few months ago.
I think we should modify the compiler so that in trailing grades it always
enabled gcc's -falign-functions option.  Alternatively we could add
an extra word at the beginning of function trail entries to store the
tag - this would have the advantage that users would not need to worry
about what is a fairly obscure point.

Estimated hours taken: 1
Branches: main

Document a subtle problem that can occur with function trailing.

Fix some failing test cases in the .tr.ll_debug grades.

 	Document that the addresses of the C functions used in function trailing
 	need to be word aligned.

 	Fix the failure of some trailing test cases in .ll_debug grades by ensuring
 	that C functions are aligned on 64-bit boundaries.  (The set of C
 	optimisations implied by the .ll_debug grades disable the -falign-functions


Index: doc/reference_manual.texi
RCS file: /home/mercury/mercury1/repository/mercury/doc/reference_manual.texi,v
retrieving revision 1.415
diff -u -r1.415 reference_manual.texi
--- doc/reference_manual.texi	14 Jan 2008 00:08:02 -0000	1.415
+++ doc/reference_manual.texi	18 Jan 2008 03:21:07 -0000
@@ -8922,6 +8922,10 @@
  If it is called with anything else (such as @samp{MR_gc}),
  then it should probably abort execution with an error message.

+Note that in the current implementation the address of the C function
+passed as the first argument of @code{MR_trail_function()} must be word
  @node Delayed goals and floundering
  @subsection Delayed goals and floundering

Index: tests/trailing/Mercury.options
RCS file: /home/mercury/mercury1/repository/tests/trailing/Mercury.options,v
retrieving revision 1.2
diff -u -r1.2 Mercury.options
--- tests/trailing/Mercury.options	6 Sep 2006 04:02:56 -0000	1.2
+++ tests/trailing/Mercury.options	18 Jan 2008 03:21:07 -0000
@@ -3,3 +3,11 @@
  MCFLAGS-tu_test1 = --analyse-trail-usage
  MCFLAGS-tu_test2 = --analyse-trail-usage
+# Note that function trailng (or at least the tagged variant thereof)
+# require that the address of functions stored on the trail is word aligned.
+# Certain, gcc optimisation settings can disable this, e.g. the ones implied
+# by the .ll_debug grades, so we need to re-enable it here.
+# (We align the function on 64-bit boundaries so that these test work
+# on either 32 or 64-bit machines.)
+EXTRA_CFLAGS = -falign-functions=8

mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au

More information about the reviews mailing list