diff options
author | Stephen Hines <srhines@google.com> | 2015-03-23 12:10:34 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2015-03-23 12:10:34 -0700 |
commit | ebe69fe11e48d322045d5949c83283927a0d790b (patch) | |
tree | c92f1907a6b8006628a4b01615f38264d29834ea /tools/lto | |
parent | b7d2e72b02a4cb8034f32f8247a2558d2434e121 (diff) | |
download | external_llvm-ebe69fe11e48d322045d5949c83283927a0d790b.zip external_llvm-ebe69fe11e48d322045d5949c83283927a0d790b.tar.gz external_llvm-ebe69fe11e48d322045d5949c83283927a0d790b.tar.bz2 |
Update aosp/master LLVM for rebase to r230699.
Change-Id: I2b5be30509658cb8266be782de0ab24f9099f9b9
Diffstat (limited to 'tools/lto')
-rw-r--r-- | tools/lto/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tools/lto/lto.cpp | 48 | ||||
-rw-r--r-- | tools/lto/lto.exports | 7 |
3 files changed, 54 insertions, 2 deletions
diff --git a/tools/lto/CMakeLists.txt b/tools/lto/CMakeLists.txt index 559b22b..87f42e8 100644 --- a/tools/lto/CMakeLists.txt +++ b/tools/lto/CMakeLists.txt @@ -1,5 +1,6 @@ set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} + Core LTO MC MCDisassembler diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp index ef37c90..714b8e0 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -14,9 +14,11 @@ #include "llvm-c/lto.h" #include "llvm/CodeGen/CommandFlags.h" +#include "llvm/IR/LLVMContext.h" #include "llvm/LTO/LTOCodeGenerator.h" #include "llvm/LTO/LTOModule.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/Signals.h" #include "llvm/Support/TargetSelect.h" // extra command-line flags needed for LTOCodeGenerator @@ -50,6 +52,12 @@ static bool parsedOptions = false; // Initialize the configured targets if they have not been initialized. static void lto_initialize() { if (!initialized) { +#ifdef LLVM_ON_WIN32 + // Dialog box on crash disabling doesn't work across DLL boundaries, so do + // it here. + llvm::sys::DisableSystemDialogsOnCrash(); +#endif + InitializeAllTargetInfos(); InitializeAllTargets(); InitializeAllTargetMCs(); @@ -213,23 +221,37 @@ void lto_codegen_set_diagnostic_handler(lto_code_gen_t cg, unwrap(cg)->setDiagnosticHandler(diag_handler, ctxt); } -lto_code_gen_t lto_codegen_create(void) { +static lto_code_gen_t createCodeGen(bool InLocalContext) { lto_initialize(); TargetOptions Options = InitTargetOptionsFromCodeGenFlags(); - LTOCodeGenerator *CodeGen = new LTOCodeGenerator(); + LTOCodeGenerator *CodeGen = + InLocalContext ? new LTOCodeGenerator(make_unique<LLVMContext>()) + : new LTOCodeGenerator(); if (CodeGen) CodeGen->setTargetOptions(Options); return wrap(CodeGen); } +lto_code_gen_t lto_codegen_create(void) { + return createCodeGen(/* InLocalContext */ false); +} + +lto_code_gen_t lto_codegen_create_in_local_context(void) { + return createCodeGen(/* InLocalContext */ true); +} + void lto_codegen_dispose(lto_code_gen_t cg) { delete unwrap(cg); } bool lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod) { return !unwrap(cg)->addModule(unwrap(mod)); } +void lto_codegen_set_module(lto_code_gen_t cg, lto_module_t mod) { + unwrap(cg)->setModule(unwrap(mod)); +} + bool lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model debug) { unwrap(cg)->setDebugInfo(debug); return false; @@ -278,6 +300,26 @@ const void *lto_codegen_compile(lto_code_gen_t cg, size_t *length) { sLastErrorString); } +bool lto_codegen_optimize(lto_code_gen_t cg) { + if (!parsedOptions) { + unwrap(cg)->parseCodeGenDebugOptions(); + lto_add_attrs(cg); + parsedOptions = true; + } + return !unwrap(cg)->optimize(DisableOpt, DisableInline, + DisableGVNLoadPRE, DisableLTOVectorization, + sLastErrorString); +} + +const void *lto_codegen_compile_optimized(lto_code_gen_t cg, size_t *length) { + if (!parsedOptions) { + unwrap(cg)->parseCodeGenDebugOptions(); + lto_add_attrs(cg); + parsedOptions = true; + } + return unwrap(cg)->compileOptimized(length, sLastErrorString); +} + bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) { if (!parsedOptions) { unwrap(cg)->parseCodeGenDebugOptions(); @@ -292,3 +334,5 @@ bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char **name) { void lto_codegen_debug_options(lto_code_gen_t cg, const char *opt) { unwrap(cg)->setCodeGenDebugOptions(opt); } + +unsigned int lto_api_version() { return LTO_API_VERSION; } diff --git a/tools/lto/lto.exports b/tools/lto/lto.exports index b10ab1a..8729050 100644 --- a/tools/lto/lto.exports +++ b/tools/lto/lto.exports @@ -6,6 +6,8 @@ lto_module_create_from_fd lto_module_create_from_fd_at_offset lto_module_create_from_memory lto_module_create_from_memory_with_path +lto_module_create_in_local_context +lto_module_create_in_codegen_context lto_module_get_deplib lto_module_get_linkeropt lto_module_get_num_deplibs @@ -20,11 +22,14 @@ lto_module_is_object_file_for_target lto_module_is_object_file_in_memory lto_module_is_object_file_in_memory_for_target lto_module_dispose +lto_api_version lto_codegen_set_diagnostic_handler lto_codegen_add_module +lto_codegen_set_module lto_codegen_add_must_preserve_symbol lto_codegen_compile lto_codegen_create +lto_codegen_create_in_local_context lto_codegen_dispose lto_codegen_set_debug_model lto_codegen_set_pic_model @@ -34,6 +39,8 @@ lto_codegen_set_assembler_args lto_codegen_set_assembler_path lto_codegen_set_cpu lto_codegen_compile_to_file +lto_codegen_optimize +lto_codegen_compile_optimized LLVMCreateDisasm LLVMCreateDisasmCPU LLVMDisasmDispose |