diff options
author | Manman Ren <manman.ren@gmail.com> | 2015-02-03 18:39:15 +0000 |
---|---|---|
committer | Manman Ren <manman.ren@gmail.com> | 2015-02-03 18:39:15 +0000 |
commit | 69e4dd1b12f6f880b1d853805d03a04a490be5f5 (patch) | |
tree | 7618583a472f83cbedf2155a8da2025f7e20454c /tools | |
parent | 42a7bc535e49af28dfa58807e8632833dcd5d01e (diff) |
[LTO API] split lto_codegen_compile to lto_codegen_optimize and
lto_codegen_compile_optimized. Also add lto_api_version.
Before this commit, we can only dump the optimized bitcode after running
lto_codegen_compile, but it includes some impacts of running codegen passes,
one example is StackProtector pass. We will get assertion failure when running
llc on the optimized bitcode, because StackProtector is effectively run twice.
After splitting lto_codegen_compile, the linker can choose to dump the bitcode
before running lto_codegen_compile_optimized.
lto_api_version is added so ld64 can check for runtime-availability of the new
API.
rdar://19565500
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228000 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/lto/lto.cpp | 20 | ||||
-rw-r--r-- | tools/lto/lto.exports | 3 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp index 74e0dbe5e37..80dca6b4d46 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -296,6 +296,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(); diff --git a/tools/lto/lto.exports b/tools/lto/lto.exports index f6ceaac74d1..9ef60772fb8 100644 --- a/tools/lto/lto.exports +++ b/tools/lto/lto.exports @@ -22,6 +22,7 @@ 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_add_must_preserve_symbol @@ -37,6 +38,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 |