llvm-6502/lib/Transforms
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
..
Hello Removed trailing whitespace from Makefiles. 2009-01-09 16:44:42 +00:00
Instrumentation Support vector casts in more places, fixing a variety of assertion 2009-06-15 22:12:54 +00:00
IPO >> What if my global variable was into a different address space than stack? 2009-06-17 06:47:15 +00:00
Scalar PR3439: Correct a silly mistake in the SimplifyDemandedUseBits code for 2009-06-17 02:57:36 +00:00
Utils Generalize instcombine's isSafeToLoadUnconditionally() function 2009-06-16 17:23:12 +00:00
Makefile I should definitely read make docs someday :( 2009-03-11 20:40:15 +00:00