llvm-6502/lib/Transforms/IPO
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
..
ArgumentPromotion.cpp Implement and use new method Function::hasAddressTaken(). 2009-06-10 08:41:11 +00:00
CMakeLists.txt Fix CMake build. Patch from Ingmar Vanhassel. 2009-06-14 13:39:56 +00:00
ConstantMerge.cpp
DeadArgumentElimination.cpp Implement and use new method Function::hasAddressTaken(). 2009-06-10 08:41:11 +00:00
DeadTypeElimination.cpp
ExtractGV.cpp
FunctionAttrs.cpp Fix PR3754: don't mark functions that wrap MallocInst with 2009-05-06 08:42:00 +00:00
GlobalDCE.cpp Remove an unused function SafeToDestroyConstant(). Rename an almost 2009-06-09 21:37:11 +00:00
GlobalOpt.cpp >> What if my global variable was into a different address space than stack? 2009-06-17 06:47:15 +00:00
IndMemRemoval.cpp
InlineAlways.cpp
Inliner.cpp available_externall linkage is not local, this was confusing the codegenerator, 2009-05-23 14:06:57 +00:00
InlineSimple.cpp
Internalize.cpp
IPConstantPropagation.cpp Use cast<> instead of dyn_cast<> for things that are known to be 2009-06-06 17:49:35 +00:00
IPO.cpp
LoopExtractor.cpp
LowerSetJmp.cpp
Makefile
MergeFunctions.cpp Unlike the other instructions, GEP really does need to look at the type of a 2009-06-13 19:09:52 +00:00
PartialInlining.cpp Merge PartialInliner changes. 2009-06-15 20:50:26 +00:00
PartialSpecialization.cpp
PruneEH.cpp
RaiseAllocations.cpp Fix old-style type names in comments. 2009-06-14 23:30:43 +00:00
StripDeadPrototypes.cpp
StripSymbols.cpp The second argument to RecursivelyDeleteTriviallyDeadInstructions has 2009-05-02 20:22:10 +00:00
StructRetPromotion.cpp