[Beignet] [PATCH 1/5] Backend: Fix printfs mem leak
Pan, Xiuli
xiuli.pan at intel.com
Fri May 6 07:56:00 UTC 2016
The PrintSlot in printfs is still copy by value, this patch only changes pointer to printfs.
-----Original Message-----
From: Luo, Xionghu
Sent: Friday, May 6, 2016 9:53 AM
To: Pan, Xiuli <xiuli.pan at intel.com>; beignet at lists.freedesktop.org
Cc: Pan, Xiuli <xiuli.pan at intel.com>
Subject: RE: [Beignet] [PATCH 1/5] Backend: Fix printfs mem leak
Need further consideration since it reverts this patch 7b151ad6c47ba169b0971e9660023cff2a6de10f.
Luo Xionghu
Best Regards
-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Xiuli Pan
Sent: Thursday, May 5, 2016 2:42 PM
To: beignet at lists.freedesktop.org
Cc: Pan, Xiuli <xiuli.pan at intel.com>
Subject: [Beignet] [PATCH 1/5] Backend: Fix printfs mem leak
From: Pan Xiuli <xiuli.pan at intel.com>
Should pass pointer of new printf_fmt into map for later delete.
Signed-off-by: Pan Xiuli <xiuli.pan at intel.com>
---
backend/src/ir/unit.cpp | 1 +
backend/src/ir/unit.hpp | 2 +-
backend/src/llvm/llvm_gen_backend.cpp | 2 +-
backend/src/llvm/llvm_printf_parser.cpp | 2 +-
4 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/backend/src/ir/unit.cpp b/backend/src/ir/unit.cpp index 5604244..c9cb15e 100644
--- a/backend/src/ir/unit.cpp
+++ b/backend/src/ir/unit.cpp
@@ -33,6 +33,7 @@ namespace ir {
}
Unit::~Unit(void) {
for (const auto &pair : functions) GBE_DELETE(pair.second);
+ for (const auto &pair : printfs) GBE_DELETE(pair.second);
delete profilingInfo;
}
Function *Unit::getFunction(const std::string &name) const { diff --git a/backend/src/ir/unit.hpp b/backend/src/ir/unit.hpp index 9b9e41f..10a1af6 100644
--- a/backend/src/ir/unit.hpp
+++ b/backend/src/ir/unit.hpp
@@ -47,7 +47,7 @@ namespace ir {
public:
typedef map<std::string, Function*> FunctionSet;
/*! Moved from printf pass */
- map<llvm::CallInst*, PrintfSet::PrintfFmt> printfs;
+ map<llvm::CallInst*, PrintfSet::PrintfFmt*> printfs;
/*! Create an empty unit */
Unit(PointerSize pointerSize = POINTER_32_BITS);
/*! Release everything (*including* the function pointers) */ diff --git a/backend/src/llvm/llvm_gen_backend.cpp b/backend/src/llvm/llvm_gen_backend.cpp
index adc626e..8bcdc49 100644
--- a/backend/src/llvm/llvm_gen_backend.cpp
+++ b/backend/src/llvm/llvm_gen_backend.cpp
@@ -726,7 +726,7 @@ namespace gbe
ir::PrintfSet::PrintfFmt* getPrintfInfo(CallInst* inst) {
if (unit.printfs.find(inst) == unit.printfs.end())
return NULL;
- return &unit.printfs[inst];
+ return unit.printfs[inst];
}
private:
void setDebugInfo_CTX(llvm::Instruction * insn); // store the debug infomation in context for subsequently passing to Gen insn diff --git a/backend/src/llvm/llvm_printf_parser.cpp b/backend/src/llvm/llvm_printf_parser.cpp
index c9ec85f..cdacb57 100644
--- a/backend/src/llvm/llvm_printf_parser.cpp
+++ b/backend/src/llvm/llvm_printf_parser.cpp
@@ -378,7 +378,7 @@ error:
}
GBE_ASSERT(unit.printfs.find(call) == unit.printfs.end());
- unit.printfs.insert(std::pair<llvm::CallInst*, PrintfSet::PrintfFmt>(call, *printf_fmt));
+ unit.printfs.insert(std::pair<llvm::CallInst*,
+ PrintfSet::PrintfFmt*>(call, printf_fmt));
return true;
}
--
2.5.0
_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/beignet
More information about the Beignet
mailing list