[LLVMdev] Localizing Globals ?

Eli Friedman eli.friedman at gmail.com
Tue Jun 16 03:10:19 PDT 2009


On Tue, Jun 16, 2009 at 2:35 AM, Sanjiv Gupta<sanjiv.gupta at microchip.com> wrote:
> What if my global variable was into a different address space than stack?

It doesn't matter in terms of semantics: because AnalyzeGlobal
returned false, we're guaranteed the address of the global is never
taken.  I wouldn't be surprised if we end up generating invalid IR in
some cases, though, because of the semantics of replaceAllUsesWith.
Do you have a testcase that breaks?

> How do I deny this optimization in that case? Can I find address space
> for stack from AllocaInst and then compare the address spaces for two?

An alloca is guaranteed to be in address space zero, so you can just
check something like "GV->getType()->getAddressSpace() == 0".

-Eli



More information about the llvm-dev mailing list