[llvm-commits] Function aliases

Reid Spencer rspencer at reidspencer.com
Fri Apr 20 13:03:22 PDT 2007


On Fri, 2007-04-20 at 10:20 +0400, Anton Korobeynikov wrote:
> Hello, Reid.
> 
> > I don't understand why we need a subclass of Function for 
> > this? Can't we just derive an "Alias" class from a smart 
> > pointer to Value?
> Because Aliases are either Function's or GlobalVariable's. They can be
> called, used in the expressions, etc. The same way as all normal
> external functions/global variables.

I'm saying don't do that. Alias is a "pointer with a name". Its an
object that says: "I'm just like that thing over there except I'm named
this". So, why not model it that way? It incurs cost only if its used.
What this does mean is that places where Functions and GVars are used,
we would also have to check for Aliases (if we cared). I assume that we
don't care in that many places. The aliasing mechanism doesn't make two
functions, there's only one function with two names. So why would we
want to instantiate two function objects?  If we instantiate an alias
object that acts like a smart pointer for the actual things, isn't that
good enough?

Reid.

> 




More information about the llvm-commits mailing list