Fix some serious logic errors that broke the jit on darwin/x86-64.
authorChris Lattner <sabre@nondot.org>
Sun, 13 Apr 2008 07:04:56 +0000 (07:04 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 13 Apr 2008 07:04:56 +0000 (07:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49606 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/JIT/JITEmitter.cpp

index 2277897d3e48979d960fd7227a5a8df9e14d9ac9..64d3cd784057f6b01d0a839a131d2f77818333e5 100644 (file)
@@ -370,17 +370,17 @@ static void AddFunctionToSymbolTable(const char *FnName,
   // If we have space in the table, reallocate the table.
   if (SymTabPtr->NumSymbols >= SymTabPtr->NumAllocated) {
     // If we don't have space, reallocate the table.
-    unsigned NewSize = std::min(64U, SymTabPtr->NumAllocated*2);
+    unsigned NewSize = std::max(64U, SymTabPtr->NumAllocated*2);
     JitSymbolEntry *NewSymbols = new JitSymbolEntry[NewSize];
     JitSymbolEntry *OldSymbols = SymTabPtr->Symbols;
     
     // Copy the old entries over.
     memcpy(NewSymbols, OldSymbols,
-           SymTabPtr->NumAllocated*sizeof(JitSymbolEntry));
+           SymTabPtr->NumSymbols*sizeof(OldSymbols[0]));
     
     // Swap the new symbols in, delete the old ones.
     SymTabPtr->Symbols = NewSymbols;
-    SymTabPtr->NumSymbols = NewSize;
+    SymTabPtr->NumAllocated = NewSize;
     delete [] OldSymbols;
   }