[llvm-commits] Function aliases

Anton Korobeynikov asl at math.spbu.ru
Thu Apr 19 23:17:42 PDT 2007


Chris,

> I don't think that really makes sense.  Aliases aren't really global  
> variables or functions themselves, they are a third kind of object.
Why the third? They definitely *are* either external functions or GVs.
For example, function aliases can be called, we can take address of
them, etc. The only difference is absence of body (because they are
"external") and two symbols they're emitting.

> What do you think about making a new GlobalAlias class, which derives  
> from GlobalValue.
And after subdivide into FunctionAlias & GlobalVariableAlias? This will
lead to code duplication, since almost all methods of Functions should
go to FunctionAlias, the same for GVs. This will also require to
carefully check all other places, where GVs and Functions are used and
change corresponding logic. Considre for example CallInst. For it we
should at least resolve issue with getCalledFunction(), which nowadays
return Function* and we should probably add new method called
getCalledFunctionAlias() or resolved the two possible return type issues
otherwise. I don't think it's worth to do so invasive changes everywhere
for such small feature.

> This would clearly solve the memory use issue
At least this will lead to code duplication in many places. 

It seems to me, there are two suitable solutions: either subclass from
Function & GlobalVariable or add instance variable to them.

-- 
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.





More information about the llvm-commits mailing list