[LLVMdev] Localizing Globals ?

Eli Friedman eli.friedman at gmail.com
Tue Jun 16 21:25:18 PDT 2009


On Tue, Jun 16, 2009 at 9:12 PM, Sanjiv Gupta<sanjiv.gupta at microchip.com> wrote:
> The problem is replaceAllUsesWith asserts for type mismatch here. Try
> attached .bc with llvm-ld.
>
> assert(New->getType() == getType() &&
>        "replaceAllUses of value with new value of different type!");

Ah, right; it probably isn't worth the effort to fix this
transformation to work with alternate address spaces.

> But then such an optimization may fail the entire idea of user wanting to
> place a variable into different memory space. The original idea of user
> might be to save on the stack space (data memory) and hence he asked the
> variable to be placed into different memory space (program memory). So the
> best bet here is to deny this optimization by checking
>
> GV->getType()->getAddressSpace() == 0.

Yeah, that sounds good; mind putting together a patch?

-Eli




More information about the llvm-dev mailing list