diff options
author | Chris Lattner <sabre@nondot.org> | 2002-02-19 18:50:09 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-02-19 18:50:09 +0000 |
commit | 9bffa73530b3712b42f6e6bddf21f22b8aba276d (patch) | |
tree | d5c202b348cd22fe87fa5ef18e3a9b8c4a6de523 /lib/ExecutionEngine/Interpreter/Execution.cpp | |
parent | ae505609206dae590ae04fe2c7b491e3a015245f (diff) |
Keep track of memory allocated by alloca so that it is freed appropriately
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1776 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/Interpreter/Execution.cpp')
-rw-r--r-- | lib/ExecutionEngine/Interpreter/Execution.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index 9f6317fd39..8b910f68af 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -741,15 +741,16 @@ void Interpreter::executeAllocInst(AllocationInst *I, ExecutionContext &SF) { } // Allocate enough memory to hold the type... - GenericValue Result; // FIXME: Don't use CALLOC, use a tainted malloc. - Result.PointerVal = (PointerTy)calloc(NumElements, TD.getTypeSize(Ty)); + void *Memory = calloc(NumElements, TD.getTypeSize(Ty)); + + GenericValue Result; + Result.PointerVal = (PointerTy)Memory; assert(Result.PointerVal != 0 && "Null pointer returned by malloc!"); SetValue(I, Result, SF); - if (I->getOpcode() == Instruction::Alloca) { - // TODO: FIXME: alloca should keep track of memory to free it later... - } + if (I->getOpcode() == Instruction::Alloca) + ECStack.back().Allocas.add(Memory); } static void executeFreeInst(FreeInst *I, ExecutionContext &SF) { |