[LLVMdev] [cfe-dev] Extend llvm to fix global addresses

Dan Gohman gohman at apple.com
Tue Dec 6 17:19:23 PST 2011


On Dec 6, 2011, at 3:29 PM, Peter Cooper wrote:

> The best case i can think of is embedded developers needing to layout functions or globals in memory.  
> Currently they would have to resort to a linker script or assembly hacks for this.  

This proposal also requires extending object file formats and linkers,
and this impacts a lot of people, so it would want a pretty
compelling motivation.

> But anything which avoids the horrible int* cast has to be a good thing.  For one thing it would cause alias analysis a lot of pain.

Actually, it wouldn't cause very much pain, if any, in alias analysis.

LLVM IR already assumes that programmers can't "guess" what the
address of the stack, global variables, or heap will be. An integer
constant casted to a pointer is assumed to be non-aliasing with
"regular" objects in memory. This property is of utmost importance,
because a pass like mem2reg relies on it to know that the allocas
it wants to promote to registers don't have their addresses
secretly taken, for example.

To support global variables at fixed addreses, you'd probably
need to make an exception to this rule, to allow these variables
to be accessed via their address values directly, which would
defeat much of the remaining benefit. These variables would
always be implicitly escaped.

I don't mean to shoot you down, but there don't seem to be any
compelling motivations for this feature.

Dan




More information about the llvm-dev mailing list