[m-dev.] diff: [deep2] avoid producing multiple predicates with the same name

Simon Taylor stayl at cs.mu.OZ.AU
Thu Feb 22 13:03:18 AEDT 2001


I've only committed this to the deep2 branch. When it is merged onto
the main branch and installed everyone will have to recompile everything,
because the names of the predicates produced for `:- pragma type_spec'
declarations have changed.

Simon.


Estimated hours taken: 0.5

compiler/higher_order.m:
	Avoid creating multiple specialized predicates
	with the same name (but with different proc_ids)
	by appending the proc_id to the name of specializations
	created for `:- pragma type_spec' declarations.
	The deep profiling transformation clones each
	procedure into another procedure in the same
	pred_info, but having multiple predicates with
	the same name made it difficult to choose a proc_id
	so that there wouldn't be name clashes at link time.

profiler/demangle.m:
util/mdemangle.c:
	Document the change to name mangling -- it doesn't
	need any special handling.

tests/misc_tests/mdemangle_test.{inp,exp}:
	Update the input and output for type specialized procedures.


Index: compiler/higher_order.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/higher_order.m,v
retrieving revision 1.83
diff -u -u -r1.83 higher_order.m
--- compiler/higher_order.m	2000/12/11 04:52:24	1.83
+++ compiler/higher_order.m	2001/02/20 05:40:25
@@ -2251,7 +2251,10 @@
 		% If this is a user-guided type specialisation, the
 		% new name comes from the name of the requesting predicate.
 		Caller = proc(CallerPredId, CallerProcId),
-		predicate_name(ModuleInfo0, CallerPredId, PredName),
+		predicate_name(ModuleInfo0, CallerPredId, PredName0),
+		proc_id_to_int(CallerProcId, CallerProcInt),
+		PredName = string__append_list(
+			[PredName0, "_", int_to_string(CallerProcInt)]),
 		SymName = qualified(PredModule, PredName),
 		NextHOid = NextHOid0,
 		NewProcId = CallerProcId,
Index: profiler/demangle.m
===================================================================
RCS file: /home/mercury1/repository/mercury/profiler/demangle.m,v
retrieving revision 1.11
diff -u -u -r1.11 demangle.m
--- profiler/demangle.m	2000/11/11 13:36:53	1.11
+++ profiler/demangle.m	2001/02/20 05:40:25
@@ -270,6 +270,12 @@
 				{ IntroducedPredType = type_spec(TypeSpec) },
 				{ Seq = 0 },
 				{ Line = 0 }
+
+				% The compiler adds a redundant mode
+				% number to the predicate name to avoid
+				% creating two predicates with the same
+				% name (deep profiling doesn't like that).
+				% It isn't used here so we just ignore it.
 			;
 				{ IntroducedPredType = IntroducedPredType0 },
 				remove_int(Line),
Index: tests/misc_tests/mdemangle_test.exp
===================================================================
RCS file: /home/mercury1/repository/tests/misc_tests/mdemangle_test.exp,v
retrieving revision 1.12
diff -u -u -r1.12 mdemangle_test.exp
--- tests/misc_tests/mdemangle_test.exp	2000/11/11 13:37:01	1.12
+++ tests/misc_tests/mdemangle_test.exp	2001/02/21 06:20:28
@@ -102,8 +102,8 @@
 
 	type specialization and deforestion
 	XXX this needs to be fixed
-<predicate 'doubleapp_impl:DeforestationIn__pred__TypeSpecOf__pred_or_func__double_app__[T = int]__21__0'/5 mode 0 (minus unused args)>
-<predicate 'doubleapp_impl:DeforestationIn__pred__TypeSpecOf__pred_or_func__double_app__[T = int]__21__0'/5 mode 0 (minus unused args)>
+<predicate 'doubleapp_impl:DeforestationIn__pred__TypeSpecOf__pred_or_func__double_app__[T = int]_0__20__0'/5 mode 0 (minus unused args)>
+<predicate 'doubleapp_impl:DeforestationIn__pred__TypeSpecOf__pred_or_func__double_app__[T = int]_0__20__0'/5 mode 0 (minus unused args)>
 
 	A realistic test
 ml -s asm_fast.gc.tr --no-demangle -o interpreter interpreter_init.o \
Index: tests/misc_tests/mdemangle_test.inp
===================================================================
RCS file: /home/mercury1/repository/tests/misc_tests/mdemangle_test.inp,v
retrieving revision 1.13
diff -u -u -r1.13 mdemangle_test.inp
--- tests/misc_tests/mdemangle_test.inp	2000/11/11 13:37:02	1.13
+++ tests/misc_tests/mdemangle_test.inp	2001/02/21 06:20:02
@@ -97,13 +97,13 @@
 <deforestation procedure (#4) from 'collect_vars' in module 'lp' line 153>
 
 	procedure introduced by type specialization
-mercury__fn__f_115_112_97_114_115_101_95_98_105_116_115_101_116_95_95_84_121_112_101_83_112_101_99_79_102_95_95_112_114_101_100_95_111_114_95_102_117_110_99_95_95_108_105_115_116_95_116_111_95_115_101_116_95_95_91_84_32_61_32_118_97_114_40_86_95_50_41_93_1_0
+mercury__fn__f_115_112_97_114_115_101_95_98_105_116_115_101_116_95_95_84_121_112_101_83_112_101_99_79_102_95_95_112_114_101_100_95_111_114_95_102_117_110_99_95_95_108_105_115_116_95_116_111_95_115_101_116_95_95_91_84_32_61_32_118_97_114_40_86_95_50_41_93_95_48_1_0
 <function 'sparse_bitset:list_to_set'/1 mode 0 (type specialized [T = var(V_2)])>
 
 	type specialization and deforestion
 	XXX this needs to be fixed
-mercury__f_100_111_117_98_108_101_97_112_112_95_105_109_112_108_95_95_68_101_102_111_114_101_115_116_97_116_105_111_110_73_110_95_95_112_114_101_100_95_95_84_121_112_101_83_112_101_99_79_102_95_95_112_114_101_100_95_111_114_95_102_117_110_99_95_95_100_111_117_98_108_101_95_97_112_112_95_95_91_84_32_61_32_105_110_116_93_95_95_50_49_95_95_48_95_95_117_97_48_5_0
-<predicate 'doubleapp_impl:DeforestationIn__pred__TypeSpecOf__pred_or_func__double_app__[T = int]__21__0'/5 mode 0 (minus unused args)>
+mercury__f_100_111_117_98_108_101_97_112_112_95_105_109_112_108_95_95_68_101_102_111_114_101_115_116_97_116_105_111_110_73_110_95_95_112_114_101_100_95_95_84_121_112_101_83_112_101_99_79_102_95_95_112_114_101_100_95_111_114_95_102_117_110_99_95_95_100_111_117_98_108_101_95_97_112_112_95_95_91_84_32_61_32_105_110_116_93_95_48_95_95_50_48_95_95_48_95_95_117_97_48_5_0
+<predicate 'doubleapp_impl:DeforestationIn__pred__TypeSpecOf__pred_or_func__double_app__[T = int]_0__20__0'/5 mode 0 (minus unused args)>
 
 	A realistic test
 ml -s asm_fast.gc.tr --no-demangle -o interpreter interpreter_init.o \
Index: util/mdemangle.c
===================================================================
RCS file: /home/mercury1/repository/mercury/util/mdemangle.c,v
retrieving revision 1.38
diff -u -u -r1.38 mdemangle.c
--- util/mdemangle.c	2000/11/11 13:36:57	1.38
+++ util/mdemangle.c	2001/02/22 01:06:43
@@ -477,6 +477,14 @@
 					category = ORDINARY;
 					start = name_before_prefixes;
 				} else {
+					/*
+					** The compiler adds a redundant mode
+					** number to the predicate name
+					** to avoid creating two predicates
+					** with the same name (deep profiling
+					** doesn't like that). It isn't used
+					** here, so we just ignore it.
+					*/
 					*end_of_lambda_pred_name = '\0';
 					start = lambda_pred_name;
 				}
--------------------------------------------------------------------------
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