[cfe-commits] r58128 - /cfe/trunk/Driver/Backend.cpp

Nuno Lopes nunoplopes at sapo.pt
Fri Oct 24 16:27:18 PDT 2008


Author: nlopes
Date: Fri Oct 24 18:27:18 2008
New Revision: 58128

URL: http://llvm.org/viewvc/llvm-project?rev=58128&view=rev
Log:
2nd try to fix leakage of the module provider. note that moduleprovider takes ownership of the module

Modified:
    cfe/trunk/Driver/Backend.cpp

Modified: cfe/trunk/Driver/Backend.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/Backend.cpp?rev=58128&r1=58127&r2=58128&view=diff

==============================================================================
--- cfe/trunk/Driver/Backend.cpp (original)
+++ cfe/trunk/Driver/Backend.cpp Fri Oct 24 18:27:18 2008
@@ -91,7 +91,6 @@
 
       delete AsmOutStream;
       delete TheTargetData;
-      delete TheModule;
       delete ModuleProvider;
       delete CodeGenPasses;
       delete PerModulePasses;
@@ -102,6 +101,7 @@
       Gen->InitializeTU(TU);
 
       TheModule = Gen->GetModule();
+      ModuleProvider = new ExistingModuleProvider(TheModule);
       TheTargetData = 
         new llvm::TargetData(TU.getContext().Target.getTargetDescription());
     }
@@ -122,7 +122,6 @@
 
 FunctionPassManager *BackendConsumer::getCodeGenPasses() const {
   if (!CodeGenPasses) {
-    ModuleProvider = new ExistingModuleProvider(TheModule);
     CodeGenPasses = new FunctionPassManager(ModuleProvider);
     CodeGenPasses->add(new TargetData(*TheTargetData));
   }
@@ -141,8 +140,7 @@
 
 FunctionPassManager *BackendConsumer::getPerFunctionPasses() const {
   if (!PerFunctionPasses) {
-    PerFunctionPasses = 
-      new FunctionPassManager(new ExistingModuleProvider(TheModule));
+    PerFunctionPasses = new FunctionPassManager(ModuleProvider);
     PerFunctionPasses->add(new TargetData(*TheTargetData));
   }
 





More information about the cfe-commits mailing list