[llvm-commits] CVS: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Dec 19 21:38:00 PST 2003
Changes in directory llvm/lib/ExecutionEngine:
ExecutionEngine.cpp updated: 1.41 -> 1.42
---
Log message:
Implement PR135, lazy emission of global variables
---
Diffs of the changes: (+7 -4)
Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp
diff -u llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.41 llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.42
--- llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.41 Fri Dec 19 20:45:37 2003
+++ llvm/lib/ExecutionEngine/ExecutionEngine.cpp Fri Dec 19 21:36:25 2003
@@ -155,7 +155,8 @@
const_cast<Function*>(dyn_cast<Function>(CPR->getValue())))
Result = PTOGV(getPointerToFunctionOrStub(F));
else
- Result = PTOGV(getPointerToGlobal(CPR->getValue()));
+ Result = PTOGV(getOrEmitGlobalVariable(
+ cast<GlobalVariable>(CPR->getValue())));
} else {
assert(0 && "Unknown constant pointer type!");
@@ -374,7 +375,6 @@
// Allocate some memory for it!
unsigned Size = TD.getTypeSize(Ty);
addGlobalMapping(I, new char[Size]);
- NumInitBytes += Size;
DEBUG(std::cerr << "Global '" << I->getName() << "' -> "
<< (void*)GlobalAddress[I] << "\n");
@@ -401,12 +401,15 @@
// EmitGlobalVariable - This method emits the specified global variable to the
// address specified in GlobalAddresses, or allocates new memory if it's not
// already in the map.
-void ExecutionEngine::EmitGlobalVariable(GlobalVariable *GV) {
+void ExecutionEngine::EmitGlobalVariable(const GlobalVariable *GV) {
void *&GA = GlobalAddress[GV];
+ const Type *ElTy = GV->getType()->getElementType();
if (GA == 0) {
// If it's not already specified, allocate memory for the global.
- GA = new char[getTargetData().getTypeSize(GV->getType()->getElementType())];
+ GA = new char[getTargetData().getTypeSize(ElTy)];
}
+
InitializeMemory(GV->getInitializer(), GA);
+ NumInitBytes += getTargetData().getTypeSize(ElTy);
++NumGlobals;
}
More information about the llvm-commits
mailing list