[m-rev.] [reuse] diff: no aliases between primitive types

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Fri Mar 30 19:18:00 AEST 2001


> On Fri, Mar 30, 2001 at 05:54:32PM +1000, Fergus Henderson wrote:
> > On 30-Mar-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> > > I have been thinking about this, I think that for the MLDS backend we
> > > are safe.  However for the LLDS backend, we aren't.
> > 
> > Even for the MLDS back-end, where float arguments are passed unboxed,
> > there might be problems because floats in structures are boxed:
> > 
> > 	:- type foo ---> f(float, float).
> > 	:- pred nasty(foo::di, foo::uo) is det.
> > 	:- pragma c_code(nasty(X::di, Y::uo), "...").
> > 
> > where the "..." is some code relying on the representation of `foo',
> > which destructively updates the memory used for `X'...
> > 
> You can declare that the two cells are aliased, as part of the pragma c
> code.  Nancy will this alias be ignored, because it involves floats.

No, it will not be ignored. The alias-system refuses to generate
such aliases from unifications, but will not check aliases that it
gets from other places. 
The same for calls to polymorphic predicates. 

E.g.: 


appendint.m:
------------ 
:- module appendint. 
:- interface.
:- import_module list, int. 

:- pred appint(list(int)::in, list(int)::in, list(int)::out) is det.

:- implementation. 

appint(L0, L1, L):- append(L0, L1, L). 

appendint.trans_opt: 
--------------------

:- module appendint.
:- use_module builtin,int,list,private_builtin.

%----------- pa_alias_info/3 ------------- 

:- pragma pa_alias_info(appendint:appint((builtin:in), (builtin:in), (builtin:out)), vars(HeadVar__1, HeadVar__2, HeadVar__3), types((list:list(int)),(list:list(int)),(list:list(int))), yes([ pair(cel(HeadVar__3, []) , cel(HeadVar__2, [])) , pair(cel(HeadVar__3, [sel((list:(.)),2,1)]) , cel(HeadVar__1, [sel((list:(.)),2,1)])) ])).

%----------- sr_reuse_info/3 ------------- 

:- pragma sr_reuse_info(appendint:appint((builtin:in), (builtin:in), (builtin:out)), vars(HeadVar__1, HeadVar__2, HeadVar__3), types((list:list(int)),(list:list(int)),(list:list(int))), yes([condition([cel(HeadVar__1, [])], [HeadVar__2, HeadVar__3], bottom)],'appendint:reuse__pred__appint__0__0')).


It's part of the to-do list to avoid the creation of these aliases. 
But still then, the aliases of floats will not be automatically 
ignored. The checking could be limited to calls to polymorphic
predicates. 

Nancy

--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list