s/Method/Function
[oota-llvm.git] / lib / ExecutionEngine / Interpreter / Execution.cpp
index 9f6317fd3937b25aae661ddcbb9b4c523f041bb5..2260625b66b8025a1b318f5d10f5c71d88711e83 100644 (file)
@@ -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) {
@@ -1027,10 +1028,8 @@ MethodInfo::MethodInfo(Method *M) : Annotation(MethodInfoAID) {
   // Assign slot numbers to the method arguments...
   const Method::ArgumentListType &ArgList = M->getArgumentList();
   for (Method::ArgumentListType::const_iterator AI = ArgList.begin(), 
-        AE = ArgList.end(); AI != AE; ++AI) {
-    MethodArgument *MA = *AI;
-    MA->addAnnotation(new SlotNumber(getValueSlot(MA)));
-  }
+        AE = ArgList.end(); AI != AE; ++AI)
+    (*AI)->addAnnotation(new SlotNumber(getValueSlot(*AI)));
 
   // Iterate over all of the instructions...
   unsigned InstNum = 0;