[LLVMdev] Localizing Globals ?
Sanjiv Gupta
sanjiv.gupta at microchip.com
Tue Jun 16 08:38:54 PDT 2009
Eli Friedman wrote:
> 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?
>
>
I do not really have a test case. I came across this when llvm-ld
crashed while working with the debug information after such optimization.
>> 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
>
As you should, this check shouldn't be required semantically as the
address is never taken, I would like to investigate more as to why
llvm-ld crashed on the debug info.
- Sanjiv
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list