1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

fix (part of) memory leak on shutdown. See PR2975.

llvm-svn: 68457
This commit is contained in:
Torok Edwin 2009-04-06 20:49:21 +00:00
parent 367120583b
commit bf09e5c8f6
2 changed files with 20 additions and 0 deletions

View File

@ -42,6 +42,7 @@
#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
@ -109,5 +110,8 @@ int main() {
// Import result of execution:
outs() << "Result: " << gv.IntVal << "\n";
EE->freeMachineCodeForFunction(FooF);
delete EE;
llvm_shutdown();
return 0;
}

View File

@ -666,6 +666,22 @@ protected:
std::multimap<unsigned, PATypeHolder> TypesByHash;
public:
~TypeMapBase()
{
for (std::multimap<unsigned, PATypeHolder>::iterator I
= TypesByHash.begin(), E = TypesByHash.end(); I != E;) {
Type *Ty = I->second.get();
if (!Ty->isAbstract() && (isa<PointerType>(Ty) || isa<FunctionType>(Ty) ||
isa<VectorType>(Ty))) {
TypesByHash.erase(I++);
// PATypeHolder won't destroy it, so we must
Ty->destroy();
}
else
++I;
}
}
void RemoveFromTypesByHash(unsigned Hash, const Type *Ty) {
std::multimap<unsigned, PATypeHolder>::iterator I =
TypesByHash.lower_bound(Hash);