aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-03-31 10:49:43 +0000
committerBill Wendling <isanbard@gmail.com>2012-03-31 10:49:43 +0000
commitcaf71d41851fa9f3efb04123de893c1f7961eed5 (patch)
tree134a09a53c8e1a8d197a16d4959b3879506e8744 /tools
parent168f1428346f3d51304db0be64e1d5e4a09ca4c2 (diff)
downloadexternal_llvm-caf71d41851fa9f3efb04123de893c1f7961eed5.zip
external_llvm-caf71d41851fa9f3efb04123de893c1f7961eed5.tar.gz
external_llvm-caf71d41851fa9f3efb04123de893c1f7961eed5.tar.bz2
Free the codegen options when deleting LTO code generator object.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153803 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/lto/LTOCodeGenerator.cpp47
1 files changed, 21 insertions, 26 deletions
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index 111f8c8..3cc13e2 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -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 @@ LTOCodeGenerator::LTOCodeGenerator()
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 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
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()));
+ }
}