[llvm-commits] [patch][8927] Add an unnamed_addr attribute
Chris Lattner
clattner at apple.com
Fri Jan 7 22:45:48 PST 2011
On Jan 7, 2011, at 7:56 PM, 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
This patch looks great except for:
> non constant globals are not allowed to have unnamed_addr since I couldn't figure out any use for it.
I also can't figure out any use for it in C, but I don't think that the verifier should reject this. The property is orthogonal from immutability.
Here's a contrived example where it could be useful: imagine a language that doesn't have pointer comparisons: in that language the frontend could mark all globals as unnamed_addr, regardless of whether they are const or not. If the optimizer realizes later that there are no stores to a global, it could be marked const, and then (because it has the attr) merged with other constant globals.
Does that make any sense?
-Chris
More information about the llvm-commits
mailing list