[llvm-commits] [patch][8927] Add an unnamed_addr attribute

Chris Lattner clattner at apple.com
Sun Jan 9 23:43:04 PST 2011


On Jan 9, 2011, at 6:37 PM, Nick Lewycky wrote:
> Rafael Ávila de Espíndola wrote:
>> This is the first step in fixing PR8927:
>> 
>> The attached patch adds a unnamed_addr bit to global constants and
>> functions. This will be used to indicate that the address is not
>> significant and therefore the constant or function can be merged with
>> others.
>> 
>> If an optimization pass can show that an address is not used, it can set
>> this.
>> 
>> Examples of things that can have this set by the FE are globals created
>> to hold string literals and C++ constructors.
>> 
>> Aliases and non constant globals are not allowed to have unnamed_addr
>> since I couldn't figure out any use for it.
>> 
>> Comments?
> 
> Silly idea, but we already have the concept of names in the IR. Why not 
> just make these anonymous?
> 
> If you think that IR names shouldn't change semantics, consider that the 
> verifier already rejects global aliases without names.

That's a clever idea.  It would be fine for things like string constants (where ".str42" isn't super helpful), but for things like vtables, it really is helpful to have names, and they are required for linkage.

-Chris



More information about the llvm-commits mailing list