[m-dev.] profiling grades broken

Tyson Richard DOWD trd at students.cs.mu.oz.au
Mon Feb 17 13:54:11 AEDT 1997


> Hi Tyson,
> 
> Your recent changes to mercury_builtin.m,
> specifically the following part, broken all the
> profiling grades.

[...]

> 
> The problem is that mercury__mercury_builtin__init() ends up
> being called twice, and this causes a number of complaints about
> duplicate labels from runtime/label.c.
> 
> Can you please fix this?

Estimated hours taken: 2

Fix a bug meant .prof grades gave duplicate label warnings.

compiler/llds_out.m:
	- Put 
	  	static bool done = FALSE; 
		if (!done) { 
			done = TRUE 
			[...  call functions ...] 
			} 
	  wrappers around calls to initialization functions.  This means
	  they can be called to avoid ordering problems, but won't cause
	  initialization to occur multiple times.  (This code is
	  #ifdefed, so only appears in grades that need to initialize
	  labels - that is non-asm, debug and .prof grades).  
	- Add some comments describing the how the output_c_module_init_list
	  predicates work.

Index: llds_out.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/llds_out.m,v
retrieving revision 1.36
diff -u -r1.36 llds_out.m
--- llds_out.m	1997/02/14 05:54:04	1.36
+++ llds_out.m	1997/02/17 02:40:39
@@ -212,6 +212,9 @@
 :- mode output_c_module_init_list(in, in, di, uo) is det.
 
 output_c_module_init_list(BaseName, Modules) -->
+
+		% Output initialization functions, bunched into groups
+		% of 40.
 	io__write_string("#if (defined(USE_GCC_NONLOCAL_GOTOS) && "),
 	io__write_string("!defined(USE_ASM_LABELS)) \\\n\t|| "),
 	io__write_string("defined(PROFILE_CALLS) || defined(DEBUG_GOTOS) \\\n"),
@@ -223,6 +226,9 @@
 	io__write_string("{\n"),
 	output_c_module_init_list_2(Modules, BaseName, 0, 40, 0, InitFuncs),
 	io__write_string("}\n\n#endif\n\n"),
+
+		% Output code to call each of the init functions created
+		% above.
 	io__write_string("void "),
 	output_init_name(BaseName),
 	io__write_string("(void);"),
@@ -236,7 +242,11 @@
 	io__write_string("defined(PROFILE_CALLS) || defined(DEBUG_GOTOS) \\\n"),
 	io__write_string("\t|| defined(DEBUG_LABELS) || !defined(SPEED) \\\n"),
 	io__write_string("\t|| defined(NATIVE_GC) \n\n"),
+	io__write_string("\tstatic bool done = FALSE;\n"),
+	io__write_string("\tif (!done) {\n"),
+	io__write_string("\t\tdone = TRUE;\n"),
 	output_c_module_init_list_3(0, BaseName, InitFuncs),
+	io__write_string("\t}\n"),
 	io__write_string("#endif\n"),
 	output_c_data_init_list(Modules),
 	io__write_string("}\n").
@@ -282,6 +292,8 @@
 	output_c_module_init_list_2(Ms, BaseName,
 		Calls1, MaxCalls, InitFunc1, InitFunc).
 
+	% Output calls to all the bunched initialization functions.
+
 :- pred output_c_module_init_list_3(int, string, int, io__state, io__state).
 :- mode output_c_module_init_list_3(in, in, in, di, uo) is det.
 
@@ -289,7 +301,7 @@
 	( { InitFunc0 > MaxInitFunc } ->
 		[]
 	;
-		io__write_string("\t"),
+		io__write_string("\t\t"),
 		output_bunch_name(BaseName, InitFunc0),
 		io__write_string("();\n"),
 		{ InitFunc1 is InitFunc0 + 1},

-- 
       Tyson Dowd           #          Another great idea from the 
                            #            people who brought you
      trd at .cs.mu.oz.au      #               Beer Milkshakes!
http://www.cs.mu.oz.au/~trd #	         Confidence --- Red Dwarf



More information about the developers mailing list