[llvm-commits] [llvm] r154306 - in /llvm/trunk: include/llvm-c/lto.h tools/lto/LTOCodeGenerator.cpp tools/lto/LTOCodeGenerator.h tools/lto/lto.cpp tools/lto/lto.exports

Bill Wendling isanbard at gmail.com
Sun Apr 8 22:26:48 PDT 2012


Author: void
Date: Mon Apr  9 00:26:48 2012
New Revision: 154306

URL: http://llvm.org/viewvc/llvm-project?rev=154306&view=rev
Log:
Add a hook to turn on the internalize pass through the LTO interface.

Modified:
    llvm/trunk/include/llvm-c/lto.h
    llvm/trunk/tools/lto/LTOCodeGenerator.cpp
    llvm/trunk/tools/lto/LTOCodeGenerator.h
    llvm/trunk/tools/lto/lto.cpp
    llvm/trunk/tools/lto/lto.exports

Modified: llvm/trunk/include/llvm-c/lto.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/lto.h?rev=154306&r1=154305&r2=154306&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/lto.h (original)
+++ llvm/trunk/include/llvm-c/lto.h Mon Apr  9 00:26:48 2012
@@ -251,6 +251,12 @@
                                int nargs);
 
 /**
+ * Enables the internalize pass during LTO optimizations.
+ */
+extern void
+lto_codegen_whole_program_optimization(lto_code_gen_t cg);
+
+/**
  * Adds to a list of all global symbols that must exist in the final
  * generated code.  If a function is not listed, it might be
  * inlined into every usage and optimized away.
@@ -258,7 +264,6 @@
 extern void
 lto_codegen_add_must_preserve_symbol(lto_code_gen_t cg, const char* symbol);
 
-
 /**
  * Writes a new object file at the specified path that contains the
  * merged contents of all modules added so far.
@@ -267,7 +272,6 @@
 extern bool
 lto_codegen_write_merged_modules(lto_code_gen_t cg, const char* path);
 
-
 /**
  * Generates code for all added modules into one native object file.
  * On success returns a pointer to a generated mach-o/ELF buffer and

Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=154306&r1=154305&r2=154306&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Mon Apr  9 00:26:48 2012
@@ -67,7 +67,7 @@
   : _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 @@
   // 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);
 

Modified: llvm/trunk/tools/lto/LTOCodeGenerator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.h?rev=154306&r1=154305&r2=154306&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.h (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.h Mon Apr  9 00:26:48 2012
@@ -54,6 +54,8 @@
   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 @@
   llvm::TargetMachine*        _target;
   bool                        _emitDwarfDebugInfo;
   bool                        _scopeRestrictionsDone;
+  bool                        _runInternalizePass;
   lto_codegen_model           _codeModel;
   StringSet                   _mustPreserveSymbols;
   StringSet                   _asmUndefinedRefs;

Modified: llvm/trunk/tools/lto/lto.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.cpp?rev=154306&r1=154305&r2=154306&view=diff
==============================================================================
--- llvm/trunk/tools/lto/lto.cpp (original)
+++ llvm/trunk/tools/lto/lto.cpp Mon Apr  9 00:26:48 2012
@@ -183,6 +183,12 @@
   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).

Modified: llvm/trunk/tools/lto/lto.exports
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.exports?rev=154306&r1=154305&r2=154306&view=diff
==============================================================================
--- llvm/trunk/tools/lto/lto.exports (original)
+++ llvm/trunk/tools/lto/lto.exports Mon Apr  9 00:26:48 2012
@@ -27,6 +27,7 @@
 lto_codegen_set_assembler_path
 lto_codegen_set_cpu
 lto_codegen_compile_to_file
+lto_codegen_whole_program_optimization
 LLVMCreateDisasm
 LLVMDisasmDispose
 LLVMDisasmInstruction





More information about the llvm-commits mailing list