2nd try to fix leakage of the module provider. note that moduleprovider takes ownership of the module

llvm-svn: 58128
This commit is contained in:
Nuno Lopes 2008-10-24 23:27:18 +00:00
parent a39a4cec35
commit 36a04c8268
1 changed files with 2 additions and 4 deletions

View File

@ -91,7 +91,6 @@ namespace {
delete AsmOutStream;
delete TheTargetData;
delete TheModule;
delete ModuleProvider;
delete CodeGenPasses;
delete PerModulePasses;
@ -102,6 +101,7 @@ namespace {
Gen->InitializeTU(TU);
TheModule = Gen->GetModule();
ModuleProvider = new ExistingModuleProvider(TheModule);
TheTargetData =
new llvm::TargetData(TU.getContext().Target.getTargetDescription());
}
@ -122,7 +122,6 @@ namespace {
FunctionPassManager *BackendConsumer::getCodeGenPasses() const {
if (!CodeGenPasses) {
ModuleProvider = new ExistingModuleProvider(TheModule);
CodeGenPasses = new FunctionPassManager(ModuleProvider);
CodeGenPasses->add(new TargetData(*TheTargetData));
}
@ -141,8 +140,7 @@ PassManager *BackendConsumer::getPerModulePasses() const {
FunctionPassManager *BackendConsumer::getPerFunctionPasses() const {
if (!PerFunctionPasses) {
PerFunctionPasses =
new FunctionPassManager(new ExistingModuleProvider(TheModule));
PerFunctionPasses = new FunctionPassManager(ModuleProvider);
PerFunctionPasses->add(new TargetData(*TheTargetData));
}