1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00
llvm-mirror/lib/Transforms/IPO
Sanjiv Gupta 6d9a123c1d >> 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. 

llvm-svn: 73605
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 Add the private linkage. 2009-01-15 20:18:42 +00:00
DeadArgumentElimination.cpp Implement and use new method Function::hasAddressTaken(). 2009-06-10 08:41:11 +00:00
DeadTypeElimination.cpp
ExtractGV.cpp Add the private linkage. 2009-01-15 20:18:42 +00:00
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 Introduce new linkage types linkonce_odr, weak_odr, common_odr 2009-03-07 15:45:40 +00:00
InlineAlways.cpp Adjustments to last patch based on review. 2009-01-09 01:30:11 +00:00
Inliner.cpp available_externall linkage is not local, this was confusing the codegenerator, 2009-05-23 14:06:57 +00:00
InlineSimple.cpp Adjustments to last patch based on review. 2009-01-09 01:30:11 +00:00
Internalize.cpp Rename getAnalysisToUpdate to getAnalysisIfAvailable. 2009-01-28 13:14:17 +00:00
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 add a bunch more passes to the C bindings (PR3734), patch by 2009-03-06 16:52:18 +00:00
LoopExtractor.cpp
LowerSetJmp.cpp
Makefile Removed trailing whitespace from Makefiles. 2009-01-09 16:44:42 +00:00
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 Keep calling-convention and tail-call bit when creating new invoke or call. 2009-03-08 19:02:17 +00:00
PruneEH.cpp Clear the cached cost when removing a function in 2009-03-19 18:03:56 +00:00
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 introduce a useful abstraction to find out if a Use is in the call position of an instruction 2009-01-22 21:35:57 +00:00