summaryrefslogtreecommitdiffstats
path: root/llvm/tools/lto/lto.cpp
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2015-02-03 18:39:15 +0000
committerManman Ren <manman.ren@gmail.com>2015-02-03 18:39:15 +0000
commit8121e1db917e2a65bfaa2f4fc59415b25f5221df (patch)
tree1a71eb558daf7fd542a12614c2d508fdbf4a843b /llvm/tools/lto/lto.cpp
parent9148e1721c08c955138746716f19d62c3657badf (diff)
downloadbcm5719-llvm-8121e1db917e2a65bfaa2f4fc59415b25f5221df.tar.gz
bcm5719-llvm-8121e1db917e2a65bfaa2f4fc59415b25f5221df.zip
[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 llvm-svn: 228000
Diffstat (limited to 'llvm/tools/lto/lto.cpp')
-rw-r--r--llvm/tools/lto/lto.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp
index 74e0dbe5e37..80dca6b4d46 100644
--- a/llvm/tools/lto/lto.cpp
+++ b/llvm/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();
OpenPOWER on IntegriCloud