[llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/Emitter.cpp

Misha Brukman brukman at cs.uiuc.edu
Sat Nov 29 18:52:01 PST 2003


Changes in directory llvm/lib/ExecutionEngine/JIT:

Emitter.cpp updated: 1.33 -> 1.34

---
Log message:

Go back to allocating memory for each constant separately. Since SPARCs do not
allow unaligned loads, that is probably the problem I've been seeing in numerous
SPARC test cases failing. X86, on the other hand, just slows down unaligned
accesses, since it must make 2 aligned accesses for each unaligned one.


---
Diffs of the changes:  (+5 -20)

Index: llvm/lib/ExecutionEngine/JIT/Emitter.cpp
diff -u llvm/lib/ExecutionEngine/JIT/Emitter.cpp:1.33 llvm/lib/ExecutionEngine/JIT/Emitter.cpp:1.34
--- llvm/lib/ExecutionEngine/JIT/Emitter.cpp:1.33	Mon Nov 17 14:40:07 2003
+++ llvm/lib/ExecutionEngine/JIT/Emitter.cpp	Sat Nov 29 18:50:53 2003
@@ -187,28 +187,13 @@
 
 void Emitter::emitConstantPool(MachineConstantPool *MCP) {
   const std::vector<Constant*> &Constants = MCP->getConstants();
-  if (Constants.size() == 0) return;
-
-  std::vector<unsigned> ConstantSizes;
-  unsigned TotalSize = 0;
-  // Calculate how much space we will need for all the constants
   for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
+    // For now we just allocate some memory on the heap, this can be
+    // dramatically improved.
     const Type *Ty = ((Value*)Constants[i])->getType();
-    unsigned TySize = TheVM->getTargetData().getTypeSize(Ty);
-    ConstantSizes.push_back(TySize);
-    TotalSize += TySize;
-  }
-  // Allocate a 'pool' of memory just once
-  void *ConstPool = malloc(TotalSize);
-  if (!ConstPool) {
-    perror("malloc");
-    abort();
-  }
-  // Initialize each slot in the 'pool' appropriately
-  for (unsigned i = 0, e = Constants.size(); i != e; ++i) {
-    TheVM->InitializeMemory(Constants[i], ConstPool);
-    ConstantPoolAddresses.push_back(ConstPool);
-    ConstPool = (void*) ((intptr_t)ConstPool + ConstantSizes[i]);
+    void *Addr = malloc(TheVM->getTargetData().getTypeSize(Ty));
+    TheVM->InitializeMemory(Constants[i], Addr);
+    ConstantPoolAddresses.push_back(Addr);
   }
 }
 





More information about the llvm-commits mailing list