summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-04-09 05:26:48 +0000
committerBill Wendling <isanbard@gmail.com>2012-04-09 05:26:48 +0000
commit3029a0c56a1e4249746ff6b54d825e88fee6cddf (patch)
tree8c20a7ce9b751377e08697c8cfd7dba23d18861e /tools
parentae1bec52f7a0e8b719e74f3575ec238094ff7599 (diff)
downloadllvm-3029a0c56a1e4249746ff6b54d825e88fee6cddf.tar.gz
llvm-3029a0c56a1e4249746ff6b54d825e88fee6cddf.tar.bz2
llvm-3029a0c56a1e4249746ff6b54d825e88fee6cddf.tar.xz
Add a hook to turn on the internalize pass through the LTO interface.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154306 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/lto/LTOCodeGenerator.cpp5
-rw-r--r--tools/lto/LTOCodeGenerator.h3
-rw-r--r--tools/lto/lto.cpp6
-rw-r--r--tools/lto/lto.exports1
4 files changed, 13 insertions, 2 deletions
diff --git a/tools/lto/LTOCodeGenerator.cpp b/tools/lto/LTOCodeGenerator.cpp
index 0e61c2fb2a..7620bcb1c1 100644
--- a/tools/lto/LTOCodeGenerator.cpp
+++ b/tools/lto/LTOCodeGenerator.cpp
@@ -67,7 +67,7 @@ LTOCodeGenerator::LTOCodeGenerator()
: _context(getGlobalContext()),
_linker("LinkTimeOptimizer", "ld-temp.o", _context), _target(NULL),
_emitDwarfDebugInfo(false), _scopeRestrictionsDone(false),
- _codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
+ _runInternalizePass(false), _codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
_nativeObjectFile(NULL) {
InitializeAllTargets();
InitializeAllTargetMCs();
@@ -366,7 +366,8 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
// Add an appropriate TargetData instance for this module...
passes.add(new TargetData(*_target->getTargetData()));
- PassManagerBuilder().populateLTOPassManager(passes, /*Internalize=*/ false,
+ PassManagerBuilder().populateLTOPassManager(passes,
+ _runInternalizePass,
!DisableInline,
DisableGVNLoadPRE);
diff --git a/tools/lto/LTOCodeGenerator.h b/tools/lto/LTOCodeGenerator.h
index 3081b7dad1..bac3e6efe9 100644
--- a/tools/lto/LTOCodeGenerator.h
+++ b/tools/lto/LTOCodeGenerator.h
@@ -54,6 +54,8 @@ struct LTOCodeGenerator {
const void *compile(size_t *length, std::string &errMsg);
void setCodeGenDebugOptions(const char *opts);
+ void enableInternalizePass() { _runInternalizePass = true; }
+
private:
bool generateObjectFile(llvm::raw_ostream &out, std::string &errMsg);
void applyScopeRestrictions();
@@ -70,6 +72,7 @@ private:
llvm::TargetMachine* _target;
bool _emitDwarfDebugInfo;
bool _scopeRestrictionsDone;
+ bool _runInternalizePass;
lto_codegen_model _codeModel;
StringSet _mustPreserveSymbols;
StringSet _asmUndefinedRefs;
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp
index a7e633d14b..e523eb3901 100644
--- a/tools/lto/lto.cpp
+++ b/tools/lto/lto.cpp
@@ -183,6 +183,12 @@ void lto_codegen_add_must_preserve_symbol(lto_code_gen_t cg,
cg->addMustPreserveSymbol(symbol);
}
+/// lto_codegen_whole_program_optimization - Enable the internalize pass during
+/// LTO optimizations.
+void lto_codegen_whole_program_optimization(lto_code_gen_t cg) {
+ cg->enableInternalizePass();
+}
+
/// lto_codegen_write_merged_modules - Writes a new file at the specified path
/// that contains the merged contents of all modules added so far. Returns true
/// on error (check lto_get_error_message() for details).
diff --git a/tools/lto/lto.exports b/tools/lto/lto.exports
index b900bfb594..1726388c0a 100644
--- a/tools/lto/lto.exports
+++ b/tools/lto/lto.exports
@@ -27,6 +27,7 @@ lto_codegen_set_assembler_args
lto_codegen_set_assembler_path
lto_codegen_set_cpu
lto_codegen_compile_to_file
+lto_codegen_whole_program_optimization
LLVMCreateDisasm
LLVMDisasmDispose
LLVMDisasmInstruction