fix three memory leaks
authorGuo Yejun <yejun.guo@intel.com>
Wed, 23 Jul 2014 23:51:18 +0000 (07:51 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Fri, 25 Jul 2014 06:32:41 +0000 (14:32 +0800)
Signed-off-by: Guo Yejun <yejun.guo@intel.com>
Reviewed-by: "Song, Ruiling" <ruiling.song@intel.com>
backend/src/llvm/llvm_printf_parser.cpp
backend/src/llvm/llvm_to_gen.cpp
src/cl_command_queue.c

index 74b57ab..384d36f 100644 (file)
@@ -543,12 +543,13 @@ error:
 
     module = F.getParent();
     intTy = IntegerType::get(module->getContext(), 32);
-    builder = new IRBuilder<>(module->getContext());
 
     // As we inline all function calls, so skip non-kernel functions
     bool bKernel = isKernelFunction(F);
     if(!bKernel) return false;
 
+    builder = new IRBuilder<>(module->getContext());
+
     /* Iter the function and find printf. */
     for (llvm::Function::iterator B = F.begin(), BE = F.end(); B != BE; B++) {
       for (BasicBlock::iterator instI = B->begin(),
index 328dbc1..3527491 100644 (file)
@@ -256,6 +256,7 @@ namespace gbe
       iter++;
     }
 
+    delete libraryInfo;
     return true;
   }
 } /* namespace gbe */
index d45e92f..842c864 100644 (file)
@@ -446,7 +446,9 @@ cl_command_queue_flush_gpgpu(cl_command_queue queue, cl_gpgpu gpgpu)
     cl_gpgpu_unmap_printf_buffer(gpgpu, 0);
     if (interp_get_printf_sizeof_size(printf_info))
       cl_gpgpu_unmap_printf_buffer(gpgpu, 1);
+  }
 
+  if (printf_info) {
     interp_release_printf_info(printf_info);
     global_wk_sz[0] = global_wk_sz[1] = global_wk_sz[2] = 0;
     cl_gpgpu_set_printf_info(gpgpu, NULL, global_wk_sz);