[LLVMdev] Localizing Globals ?
sanjiv.gupta at microchip.com
Tue Jun 16 02:35:18 PDT 2009
The code excerpt is from IPO/GlobalOpt.cpp
// If this is a first class global and has only one accessing function
// and this function is main (which we know is not recursive we can make
// this global a local variable) we replace the global with a local
// in this function.
// NOTE: It doesn't make sense to promote non single-value types
// are just replacing static memory to stack memory.
if (!GS.HasMultipleAccessingFunctions &&
GS.AccessingFunction && !GS.HasNonInstructionUser &&
GS.AccessingFunction->getName() == "main" &&
DOUT << "LOCALIZING GLOBAL: " << *GV;
What if my global variable was into a different address space than stack?
How do I deny this optimization in that case? Can I find address space
for stack from AllocaInst and then compare the address spaces for two?
More information about the llvm-dev