[m-dev.] ground->clobbered argument modes

Simon Taylor stayl at cs.mu.OZ.AU
Wed Aug 4 16:07:05 AEST 1999


Hi,

There are a couple of modules in the compiler (pd_info.m, typecheck.m)
which use `ground' instead of `unique' for initial insts because aliasing
doesn't work properly. They still use `clobbered' for the final insts,
resulting in the mode of some arguments of some predicates being
`ground -> clobbered'. This can cause problems when rerunning mode
analysis in the alias branch after some calls have been inlined.

In the clause for sc1/4 below, if the call to sc_get/3 is inlined and the
call to sc_set/3 is not inlined, a mode error results. There appears
to be an uncaught mode error in sc_get/3 -- the first argument (which is
live after the predicate returns) is aliased to the first field of the second
argument, for which the final inst in the argument modes is `clobbered'.

Any ideas on how mode analysis is supposed to treat this case?
One possible fix would be to unify the uniqueness (but not the bindings)
of the final insts in the argument modes with the final insts of
the argument variables before calling inst_matches_final.

Simon.



:- module sc.

:- interface.

:- type foo
	---> foo(
		int,
		int,
		int
	).

:- mode sc :: ground -> dead.

:- pred sc1(int::in, int::out, foo::sc, foo::out) is det.
:- pred sc2(int::in, int::out, foo::sc, foo::out) is det.

:- pred sc_get(int::out, foo::sc, foo::out) is det.
:- pred sc_set(int::in, foo::sc, foo::out) is det.

:- implementation.

sc1(A, B, Foo0, Foo) :-
	sc_get(B, Foo0, Foo1),
	sc_set(A, Foo1, Foo).

sc2(A, B, Foo0, Foo) :-
	Foo0 = foo(B, _, _),
	Foo1 = Foo0,
	sc_set(A, Foo1, Foo).

sc_get(A, foo(A, B, C), foo(A, B, C)).
sc_set(A, foo(_, B, C), foo(A, B, C)).

sc.m:027: In clause for `sc2(in, out, (sc:sc), out)':
sc.m:027:   mode error: argument 2 did not get sufficiently instantiated.
sc.m:027:   Final instantiatedness of `HeadVar__2' was `clobbered',
sc.m:027:   expected final instantiatedness was `ground'.
For more information, try recompiling with `-E'.
--------------------------------------------------------------------------
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