[m-rev.] diff: fix for bug #48

Julien Fischer juliensf at csse.unimelb.edu.au
Wed Mar 26 13:08:51 AEDT 2008


On Wed, 26 Mar 2008, Mark Brown wrote:

> This change addresses the problem with compiling analysis.m.  However, a
> couple of people from the G12 group have reported similar looking errors,
> and this change does not fix those.  There may be more than one bug
> involved, so I'm going to commit this before investigating further.
> I'll back this change out if we find that it is wrong.
>
> Note that bootchecks in asm_fast.gc.decldebug still segfault in stage 3,
> as they were doing before this change.

Is this just on pluto or on all machines?
(BTW valgrind is now installed on pluto.)

> Estimated hours taken: 20
> Branches: main
>
> Fix a failure to compile analysis.m in grade asm_fast.gc.decldebug.  The
> problem was that common.m would leave references to type-info variables
> that are assigned (i.e., introduced by common.m) rather than the type-infos
> that come from constructions, deconstructions or procedure calls.  Later
> on, excess-assignment removal may leave these as dangling references.
>
> The fix is to always ensure that we refer to the original type-info, not
> the assigned one.
>
> compiler/common.m:
> 	When generating an assignment, first apply substitutions to the
> 	RttiVarMaps which eliminate the "To" variable in favor of the
> 	"From" variable.  Then duplicate the information for the "To"
> 	variable.
>
> compiler/simplify.m:
> 	Export a procedure to perform the above steps on a simplify_info.
>
> compiler/hlds_rtti.m:
> 	Make use of the prog_var_renaming type.
>
> compiler/Mercury.options:
> 	Add a note that the workaround can be removed once the compiler
> 	is installed.
>
> Index: compiler/Mercury.options
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/Mercury.options,v
> retrieving revision 1.36
> diff -u -r1.36 Mercury.options
> --- compiler/Mercury.options	28 Feb 2008 00:47:24 -0000	1.36
> +++ compiler/Mercury.options	26 Mar 2008 01:30:50 -0000
> @@ -52,6 +52,8 @@
> # Bug workarounds
>
> # This works around bug 48 in Mantis.
> +# (This has been fixed, and the workaround can be removed once new compilers
> +# have been installed.)
> MCFLAGS-analysis = --no-common-struct
>
> # XXX work around a bug that sometimes appears at -O4 and above.
> Index: compiler/common.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/common.m,v
> retrieving revision 1.105
> diff -u -r1.105 common.m
> --- compiler/common.m	28 Feb 2008 06:08:29 -0000	1.105
> +++ compiler/common.m	26 Mar 2008 01:30:50 -0000
> @@ -770,7 +770,7 @@
>     is det.
>
> generate_assign(ToVar, FromVar, UniMode, _, Goal, !Info) :-
> -    apply_induced_tsubst(ToVar, FromVar, !Info),
> +    apply_induced_substitutions(ToVar, FromVar, !Info),
>     simplify_info_get_var_types(!.Info, VarTypes),
>     map.lookup(VarTypes, ToVar, ToVarType),
>     map.lookup(VarTypes, FromVar, FromVarType),
> @@ -842,15 +842,20 @@
>     % rtti_varmaps.  This allows us to avoid an unsafe cast, and also may
>     % allow more opportunities for simplification.
>     %
> +    % If we do need to apply a type substitution, then we also apply the
> +    % substituion ToVar -> FromVar to the RttiVarMaps, then duplicate

s/substituion/substitution/

> +    % FromVar's information for ToVar.  This ensures we always refer to the
> +    % "original" variables, not the copies created by generate_assign.
> +    %
>     % Note that this relies on the assignments for type_infos and
>     % typeclass_infos to be generated before other arguments with these

s/to be/being/

>     % existential types are processed.  In other words, the arguments of
>     % calls and deconstructions must be processed in left to right order.
>     %
> -:- pred apply_induced_tsubst(prog_var::in, prog_var::in, simplify_info::in,
> -    simplify_info::out) is det.
> +:- pred apply_induced_substitutions(prog_var::in, prog_var::in,
> +    simplify_info::in, simplify_info::out) is det.

That looks okay.

Julien.
--------------------------------------------------------------------------
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