llvm-6502/lib
Sanjiv Gupta 059aa8c604 >> 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?
>
>   
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!");

Since stack is always on address space zero, I don't think that type of GV in a different address space is ever going to match.
The other way is to allow replaceAllUsesWith to ignore address spaces while comparing types. (do we have  a way to do that ?).
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. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73605 91177308-0d34-0410-b5e6-96231b3b80d8
2009-06-17 06:47:15 +00:00
..
Analysis Fix ScalarEvolution's Xor handling to not assume that an And 2009-06-17 01:22:39 +00:00
Archive Avoid leaking memory in an error path. Noticed 2009-06-11 08:09:49 +00:00
AsmParser Address review comments: add 3 ARM calling conventions. 2009-06-16 18:50:49 +00:00
Bitcode Fix PR4336: Iterating over use-def chains doesn't seem to be deterministic. 2009-06-16 05:15:21 +00:00
CodeGen Fixed names of libcalls checked in r73480. 2009-06-16 10:22:58 +00:00
CompilerDriver -write-graph now can be used with -o. 2009-03-27 12:57:14 +00:00
Debugger Oops...I committed too much. 2009-03-13 04:39:26 +00:00
ExecutionEngine Fix the EE bindings to use the proper EE interfaces for creating a JIT. 2009-06-16 22:26:13 +00:00
Linker Add a new "available_externally" linkage type. This is intended 2009-04-13 05:44:34 +00:00
Support Add newline at end of file. 2009-06-16 20:53:09 +00:00
System Use atomic increment/decrement for reference counting of Type's. 2009-06-17 00:28:49 +00:00
Target Do not use first actual instruction's location for prologue. The debug wants to skip prologue while setting a breakpoint for the function. 2009-06-17 00:48:26 +00:00
Transforms >> What if my global variable was into a different address space than stack? 2009-06-17 06:47:15 +00:00
VMCore Add locking around the accessors for AbstractTypeUsers. 2009-06-17 00:12:30 +00:00
Makefile Reorganize llvmc code. 2009-03-02 09:01:14 +00:00