llvm.org GIT mirror llvm / 3029a0c
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 Bill Wendling 7 years ago
5 changed file(s) with 19 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
250250 int nargs);
251251
252252 /**
253 * Enables the internalize pass during LTO optimizations.
254 */
255 extern void
256 lto_codegen_whole_program_optimization(lto_code_gen_t cg);
257
258 /**
253259 * Adds to a list of all global symbols that must exist in the final
254260 * generated code. If a function is not listed, it might be
255261 * inlined into every usage and optimized away.
257263 extern void
258264 lto_codegen_add_must_preserve_symbol(lto_code_gen_t cg, const char* symbol);
259265
260
261266 /**
262267 * Writes a new object file at the specified path that contains the
263268 * merged contents of all modules added so far.
265270 */
266271 extern bool
267272 lto_codegen_write_merged_modules(lto_code_gen_t cg, const char* path);
268
269273
270274 /**
271275 * Generates code for all added modules into one native object file.
6666 : _context(getGlobalContext()),
6767 _linker("LinkTimeOptimizer", "ld-temp.o", _context), _target(NULL),
6868 _emitDwarfDebugInfo(false), _scopeRestrictionsDone(false),
69 _codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
69 _runInternalizePass(false), _codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
7070 _nativeObjectFile(NULL) {
7171 InitializeAllTargets();
7272 InitializeAllTargetMCs();
365365 // Add an appropriate TargetData instance for this module...
366366 passes.add(new TargetData(*_target->getTargetData()));
367367
368 PassManagerBuilder().populateLTOPassManager(passes, /*Internalize=*/ false,
368 PassManagerBuilder().populateLTOPassManager(passes,
369 _runInternalizePass,
369370 !DisableInline,
370371 DisableGVNLoadPRE);
371372
5353 const void *compile(size_t *length, std::string &errMsg);
5454 void setCodeGenDebugOptions(const char *opts);
5555
56 void enableInternalizePass() { _runInternalizePass = true; }
57
5658 private:
5759 bool generateObjectFile(llvm::raw_ostream &out, std::string &errMsg);
5860 void applyScopeRestrictions();
6971 llvm::TargetMachine* _target;
7072 bool _emitDwarfDebugInfo;
7173 bool _scopeRestrictionsDone;
74 bool _runInternalizePass;
7275 lto_codegen_model _codeModel;
7376 StringSet _mustPreserveSymbols;
7477 StringSet _asmUndefinedRefs;
182182 cg->addMustPreserveSymbol(symbol);
183183 }
184184
185 /// lto_codegen_whole_program_optimization - Enable the internalize pass during
186 /// LTO optimizations.
187 void lto_codegen_whole_program_optimization(lto_code_gen_t cg) {
188 cg->enableInternalizePass();
189 }
190
185191 /// lto_codegen_write_merged_modules - Writes a new file at the specified path
186192 /// that contains the merged contents of all modules added so far. Returns true
187193 /// on error (check lto_get_error_message() for details).
2626 lto_codegen_set_assembler_path
2727 lto_codegen_set_cpu
2828 lto_codegen_compile_to_file
29 lto_codegen_whole_program_optimization
2930 LLVMCreateDisasm
3031 LLVMDisasmDispose
3132 LLVMDisasmInstruction