[llvm-commits] [llvm] r50008 - in /llvm/trunk/lib/ExecutionEngine/JIT: JITDwarfEmitter.cpp JITEmitter.cpp
Nicolas Geoffray
nicolas.geoffray at lip6.fr
Sun Apr 20 16:39:44 PDT 2008
Author: geoffray
Date: Sun Apr 20 18:39:44 2008
New Revision: 50008
URL: http://llvm.org/viewvc/llvm-project?rev=50008&view=rev
Log:
Be pessimistic in computing the buffer size when aligning.
Modified:
llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp
llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp?rev=50008&r1=50007&r2=50008&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp Sun Apr 20 18:39:44 2008
@@ -664,7 +664,8 @@
/// the new value.
static unsigned RoundUpToAlign(unsigned FinalSize, unsigned Alignment) {
if (Alignment == 0) Alignment = 1;
- return (FinalSize + Alignment - 1) & ~(Alignment - 1);
+ // Since we do not know where the buffer will be allocated, be pessimistic.
+ return FinalSize + Alignment;
}
unsigned
Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=50008&r1=50007&r2=50008&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Sun Apr 20 18:39:44 2008
@@ -623,9 +623,10 @@
return NumEntries * EntrySize;
}
-static void AddAlignment(uintptr_t& Size, unsigned Alignment) {
+static uintptr_t RoundUpToAlign(uintptr_t Size, unsigned Alignment) {
if (Alignment == 0) Alignment = 1;
- Size = (Size + Alignment - 1) & (Alignment - 1);
+ // Since we do not know where the buffer will be allocated, be pessimistic.
+ return Size + Alignment;
}
void JITEmitter::startFunction(MachineFunction &F) {
@@ -636,22 +637,24 @@
MachineConstantPool *MCP = F.getConstantPool();
// Ensure the constant pool/jump table info is at least 4-byte aligned.
- AddAlignment(ActualSize, 16);
+ ActualSize = RoundUpToAlign(ActualSize, 16);
// Add the alignment of the constant pool
- AddAlignment(ActualSize, 1 << MCP->getConstantPoolAlignment());
+ ActualSize = RoundUpToAlign(ActualSize,
+ 1 << MCP->getConstantPoolAlignment());
// Add the constant pool size
ActualSize += GetConstantPoolSizeInBytes(MCP);
// Add the aligment of the jump table info
- AddAlignment(ActualSize, MJTI->getAlignment());
+ ActualSize = RoundUpToAlign(ActualSize, MJTI->getAlignment());
// Add the jump table size
ActualSize += GetJumpTableSizeInBytes(MJTI);
// Add the alignment for the function
- AddAlignment(ActualSize, std::max(F.getFunction()->getAlignment(), 8U));
+ ActualSize = RoundUpToAlign(ActualSize,
+ std::max(F.getFunction()->getAlignment(), 8U));
// Add the function size
ActualSize += TII->GetFunctionSizeInBytes(F);
More information about the llvm-commits
mailing list