[m-rev.] Fix compiling of injection under the IL backend

Jonathan Morgan jonmmorgan at gmail.com
Thu Jan 4 23:27:59 AEDT 2007


Estimated hours taken: 2.5
Branches: main

Fix a bug in the IL backend, which appeared in the compilation of
injection.delete_values with inlining on.  The code generator was
sometimes generating functions and predicates which only differed in
the return type when inlining higher order terms.  This caused
duplicate method errors in the generated IL.  The fix is to alter the
name mangling routine so that it always distinguishes between
functions and predicates.

compiler/mlds_to_il.m:
    Add "_f" to all functions when mangling MLDS procedure names.

Index: compiler/mlds_to_il.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_il.m,v
retrieving revision 1.176
diff -u -r1.176 mlds_to_il.m
--- compiler/mlds_to_il.m	3 Jan 2007 11:22:32 -0000	1.176
+++ compiler/mlds_to_il.m	4 Jan 2007 12:05:02 -0000
@@ -3258,8 +3258,13 @@
     %     in = out) may clash with a predicate which has the
     %     same types and modes.
     %
-    %     To avoid this, we mangle all functions with
-    %     non-default modes by adding _f to the procedure name.
+    %     In addition, a function may clash with a predicate which
+    %     has the same types and modes and has been introduced
+    %     by inlining.These will then differ only in return type,
+    %     which is forbidden.
+    %
+    %     To avoid this, we mangle all functions by adding _f
+    %     to the procedure name.
     %
     %   - Problem:
     %     A predicate or function with more than one mode.
@@ -3287,7 +3292,7 @@
     % user names in the case where there is a <modulename>. - fjh
     %
 predlabel_to_id(mlds_user_pred_label(PredOrFunc, MaybeModuleName, Name, Arity,
-        CodeModel, NonOutputFunc), ProcId, MaybeSeqNum, Id) :-
+        CodeModel, _NonOutputFunc), ProcId, MaybeSeqNum, Id) :-
     (
         MaybeModuleName = yes(ModuleName),
         mlds_to_il.sym_name_to_string(ModuleName, MStr),
@@ -3297,17 +3302,15 @@
         MaybeModuleStr = ""
     ),
     (
-        CodeModel = model_semi,
-        PredOrFunc = predicate
-    ->
-        PredOrFuncStr = "_p"
+        PredOrFunc = predicate,
+        ( CodeModel = model_semi ->
+            PredOrFuncStr = "_p"
+        ;
+            PredOrFuncStr = ""
+        )
     ;
         PredOrFunc = function,
-        NonOutputFunc = yes
-    ->
         PredOrFuncStr = "_f"
-    ;
-        PredOrFuncStr = ""
     ),
     proc_id_to_int(ProcId, ProcIdInt),
     ( ProcIdInt = 0 ->
--------------------------------------------------------------------------
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