[llvm-commits] [llvm] r153803 - /llvm/trunk/tools/lto/LTOCodeGenerator.cpp

Bill Wendling isanbard at gmail.com
Sat Mar 31 03:49:43 PDT 2012


Author: void
Date: Sat Mar 31 05:49:43 2012
New Revision: 153803

URL: http://llvm.org/viewvc/llvm-project?rev=153803&view=rev
Log:
Free the codegen options when deleting LTO code generator object.

Modified:
    llvm/trunk/tools/lto/LTOCodeGenerator.cpp

Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=153803&r1=153802&r2=153803&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Sat Mar 31 05:49:43 2012
@@ -51,24 +51,19 @@
 #include <cstdlib>
 #include <unistd.h>
 #include <fcntl.h>
-
-
 using namespace llvm;
 
 static cl::opt<bool> DisableInline("disable-inlining",
   cl::desc("Do not run the inliner pass"));
 
-
-const char* LTOCodeGenerator::getVersionString()
-{
+const char* LTOCodeGenerator::getVersionString() {
 #ifdef LLVM_VERSION_INFO
-    return PACKAGE_NAME " version " PACKAGE_VERSION ", " LLVM_VERSION_INFO;
+  return PACKAGE_NAME " version " PACKAGE_VERSION ", " LLVM_VERSION_INFO;
 #else
-    return PACKAGE_NAME " version " PACKAGE_VERSION;
+  return PACKAGE_NAME " version " PACKAGE_VERSION;
 #endif
 }
 
-
 LTOCodeGenerator::LTOCodeGenerator() 
     : _context(getGlobalContext()),
       _linker("LinkTimeOptimizer", "ld-temp.o", _context), _target(NULL),
@@ -81,13 +76,14 @@
     InitializeAllAsmPrinters();
 }
 
-LTOCodeGenerator::~LTOCodeGenerator()
-{
-    delete _target;
-    delete _nativeObjectFile;
-}
-
+LTOCodeGenerator::~LTOCodeGenerator() {
+  delete _target;
+  delete _nativeObjectFile;
 
+  for (std::vector<const char*>::iterator I = _codegenOptions.begin(),
+         E = _codegenOptions.end(); I != E; ++I)
+    free(*I);
+}
 
 bool LTOCodeGenerator::addModule(LTOModule* mod, std::string& errMsg)
 {
@@ -416,16 +412,15 @@
     return false; // success
 }
 
-
-/// Optimize merged modules using various IPO passes
-void LTOCodeGenerator::setCodeGenDebugOptions(const char* options)
-{
-    for (std::pair<StringRef, StringRef> o = getToken(options);
-         !o.first.empty(); o = getToken(o.second)) {
-        // ParseCommandLineOptions() expects argv[0] to be program name.
-        // Lazily add that.
-        if ( _codegenOptions.empty() ) 
-            _codegenOptions.push_back("libLTO");
-        _codegenOptions.push_back(strdup(o.first.str().c_str()));
-    }
+/// setCodeGenDebugOptions - Set codegen debugging options to aid in debugging
+/// LTO problems.
+void LTOCodeGenerator::setCodeGenDebugOptions(const char *options) {
+  for (std::pair<StringRef, StringRef> o = getToken(options);
+       !o.first.empty(); o = getToken(o.second)) {
+    // ParseCommandLineOptions() expects argv[0] to be program name. Lazily add
+    // that.
+    if ( _codegenOptions.empty() )
+      _codegenOptions.push_back(strdup("libLTO"));
+    _codegenOptions.push_back(strdup(o.first.str().c_str()));
+  }
 }





More information about the llvm-commits mailing list