🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #1964

Re: Whether cc after f2c can optimize arrays as well as f77 can

#1964
From: Jim Giles
Date: Thu, 08 Nov 1990 00:47
54 lines
2910 bytes
Well, I've looked over your little proposal.  And, I'll have to admit
that it does "solve" the specific problem I posted.  If I had known
the misapprehension you were under about the problem I was addressing,
I would have posted a different example.  However, I will address three
objections to your scheme:

1) The number of different possible partitions is exponential in the
   number of procedure arguments, and is further enlarged by additional
   aliasing possibilities from the global variables.  To get the
   efficiency of the scheme I've been recommending, you would either
   have to always generate code for each possible partition of the
   variables, or the user would have to make his aliasing assertions
   as prolific as the scheme I am suggesting (to cause the generation
   of the specific partitions that the code actually needs).  Your
   scheme has the 'advantage' of automatically working even without
   these assertions.

2) I put the word 'advantage' in apostrophes above because I don't
   really consider it an advantage.  Usually, when unexpected aliasing
   occurs in a program it is an error.  Your scheme just goes ahead
   and runs without giving any indication to the user that deep down
   some aliasing has occurred.  This is the kind of obscure and hard
   to find error that was part of the motivation for the scheme that
   am proposing.

3) The last of these objections to your scheme is the fact that the
   first counter-example I tried actually couldn't be done correctly
   by your method:

      static int a;
      main() {
      ...
	 sub(&a);
      ...
      }
      fcn((int *) x) {
      ...
	 /* is 'x' aliased to 'a' here? */
      ...
      }

   Here, sub() is a procedure in a library (that you may or may not
   have the source for).  The procedure fcn() will be called at some
   time by the library.  The question is whether the parameter '&a'
   is passed through the library and back to fcn().  Since the variable
   'a' is declared 'static' (which for some reason, C interprets in
   this context to mean 'private'), 'a' does not show up in any of the
   partition comparisons in the library - in fact, 'a' is completely
   free from aliasing while in the library.  But, unless you do a
   call-chain analysis that propagates procedure arguments you will
   not be able to determine if 'x' and 'a' are aliased in fcn().
   This is one of the things that my scheme _can_ do.

J. Giles
Technical Details
Message-ID: <5243@lanl.gov>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!lanl!jlg
References: <2779:Nov608:20:1990@kramden.acf.nyu.edu> <5085@lanl.gov>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!lanl!jlg
From: jlg@lanl.gov (Jim Giles)
Newsgroups: comp.lang.misc
Subject: Re: Whether cc after f2c can optimize arrays as well as f77 can
Message-ID: <5243@lanl.gov>
Date: 8 Nov 90 00:47:26 GMT
References: <2779:Nov608:20:1990@kramden.acf.nyu.edu> <5085@lanl.gov>
Organization: Los Alamos Natl Lab, Los Alamos, N.M.
Lines: 54