[opengtl-commits] [567] fix the memory manager

[ Thread Index | Date Index | More lists.tuxfamily.org/opengtl-commits Archives ]


Revision: 567
Author:   cyrille
Date:     2009-02-27 19:47:12 +0100 (Fri, 27 Feb 2009)

Log Message:
-----------
fix the memory manager

Modified Paths:
--------------
    trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp


Modified: trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp
===================================================================
--- trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp	2009-02-27 17:29:30 UTC (rev 566)
+++ trunk/OpenGTL/OpenGTL/GTLCore/CodeGenerator_p.cpp	2009-02-27 18:47:12 UTC (rev 567)
@@ -730,14 +730,14 @@
   return val;
 }
 
-// #define _USE_GTL_MM_
+#define _USE_GTL_MM_
 
 #ifdef _USE_GTL_MM_
 
 llvm::Function* createGtlMallocFunction( llvm::Module* _module )
 {
   std::vector<const llvm::Type*> memcpyTyArgs;
-  memcpyTyArgs.push_back(llvm::IntegerType::get(32));
+  memcpyTyArgs.push_back(llvm::Type::Int32Ty);
   llvm::FunctionType* memcpyTy = llvm::FunctionType::get( llvm::PointerType::get(llvm::IntegerType::get(8), 0), memcpyTyArgs, false);
   
   llvm::Function* func_llvm_memcpy_i32 = (llvm::Function*)_module->getOrInsertFunction(
@@ -764,7 +764,12 @@
 #ifdef _USE_GTL_MM_
   llvm::Function* func = createGtlMallocFunction( _gc.module()->llvmModule() );
   std::vector<llvm::Value*> params;
-  params.push_back( llvm::BinaryOperator::createMul( _size, llvm::ConstantExpr::getSizeOf( _type ), "", _bb  ) );
+  GTL_DEBUG( *_size << "  * " << *llvm::ConstantExpr::getSizeOf( _type ) );
+  params.push_back( llvm::BinaryOperator::createMul( 
+    _size,
+    llvm::CastInst::CreateIntegerCast( llvm::ConstantExpr::getSizeOf( _type ),
+                                       llvm::Type::Int32Ty, false, "", _bb ), "", _bb  ) );
+  GTL_DEBUG( *func );
   llvm::CallInst *CallFunc = llvm::CallInst::Create(func, params.begin(), params.end(), "", _bb);
   CallFunc->setTailCall(false);
   return convertPointerTo( _bb, CallFunc, _type );
@@ -778,7 +783,8 @@
 #ifdef _USE_GTL_MM_
   llvm::Function* func = createGtlFreeFunction( _gc.module()->llvmModule() );
   std::vector<llvm::Value*> params;
-  params.push_back( convertPointerTo( _bb, _ptr, llvm::PointerType::get(llvm::IntegerType::get(8), 0) )  );
+  params.push_back( convertPointerTo( _bb, _ptr, llvm::IntegerType::get(8) ) );
+  GTL_DEBUG(*params[0]);
   llvm::CallInst *CallFunc = llvm::CallInst::Create(func, params.begin(), params.end(), "", _bb);
   CallFunc->setTailCall(false);
 #else


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/