From: Misha Brukman Date: Sun, 30 Nov 2003 00:50:53 +0000 (+0000) Subject: Go back to allocating memory for each constant separately. Since SPARCs do not X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=91de352796a52e5d18b19f0be322677b1cf6b176;p=oota-llvm.git 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10266 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp index be60b239a3e..32d0651f226 100644 --- a/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -187,28 +187,13 @@ void Emitter::finishFunction(MachineFunction &F) { void Emitter::emitConstantPool(MachineConstantPool *MCP) { const std::vector &Constants = MCP->getConstants(); - if (Constants.size() == 0) return; - - std::vector 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); } }