[llvm-commits] Function aliases

Chris Lattner clattner at apple.com
Thu Apr 19 11:51:30 PDT 2007


>> First, you are changing the LLVM language.  When you do this, please
>> submit a patch for langref before you write code :).  In this case,
>> I'd like to see the patch so that I understand the semantics of what
>> you're proposing.
> Ok. However language semantics was already discussed with you and Reid
> some time ago :) The syntax itself is:
>
> declare %i32 foo(...) alias "bar"

Ok, does this also apply to functions with bodies?

>> Do aliases only apply to function-like things, or can they also apply
>> to global vars?
> Aliases are "hacks". I don't see any field, where they can be useful,
> except gcc support. GCC doesn't allow variable aliases and I don't  
> know
> how they should look (and work!). That's why I'm focusing on function
> aliases only.

Ok

>> This needs a block comment above it for doxygen, explaining what it
>> is.  Also, you have FunctionAlias.  Is there also a
>> GlobalVariableAlias?  Why does this inherit from Function?  Can
>> FunctionAliases have a body?  If not, it shouldn't inherit from
>> Function.
> FunctionAliases are actually Functions declarations with some "extra"
> information. That's why they should be inherited from Function.  
> Another
> reason: this will allow all optimization passes think about
> FunctionAliases as Functions and use casts if they actually need alias
> target

If they can have bodies, why not just make this an instance variable  
in the Function class?  If the string is empty, there is no alias.

>> +  if (TAI->getSetDirective()) {
>> +    if (FunctionAliases.begin() != FunctionAliases.end())
>> if (!FunctionAliases.empty())
> I saw such idiom many time in the current LLVM code. That's why I
> selected it :)

Ok, they should be fixed! :)

>> Other stuff: should the verifier reject aliases with no name?
> Yes, I've forgotten about this.

Ok

>>   How do aliases interact with the Linker?
> Linker patch was included. Currently we're linking two aliases only if
> they have same name and go to the same destination.

The question is, what happens if we link something like this:


void foo() alias bar {}

---

extern void bar();
void baz() { bar(); }

Do the two functions (the extern of bar and the decl of foo) get  
linked up?  What happens if the foo declaration was a prototype with  
no body?

-Chris



More information about the llvm-commits mailing list