Add a libLTO API to stop/restart ThinLTO between optimizations and CodeGen
This allows the linker to instruct ThinLTO to perform only the
optimization part or only the codegen part of the process.
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 265113
diff --git a/llvm/include/llvm-c/lto.h b/llvm/include/llvm-c/lto.h
index 42c2802..82f7fd7 100644
--- a/llvm/include/llvm-c/lto.h
+++ b/llvm/include/llvm-c/lto.h
@@ -44,7 +44,8 @@
* @{
*/
-#define LTO_API_VERSION 18
+#define LTO_API_VERSION 19
+
/**
* \since prior to LTO_API_VERSION=3
*/
@@ -718,6 +719,23 @@
extern void thinlto_codegen_set_cpu(thinlto_code_gen_t cg, const char *cpu);
/**
+ * Disable CodeGen, only run the stages till codegen and stop. The output will
+ * be bitcode.
+ *
+ * \since LTO_API_VERSION=19
+ */
+extern void thinlto_codegen_disable_codegen(thinlto_code_gen_t cg,
+ lto_bool_t disable);
+
+/**
+ * Perform CodeGen only: disable all other stages.
+ *
+ * \since LTO_API_VERSION=19
+ */
+extern void thinlto_codegen_set_codegen_only(thinlto_code_gen_t cg,
+ lto_bool_t codegen_only);
+
+/**
* Parse -mllvm style debug options.
*
* \since LTO_API_VERSION=18
diff --git a/llvm/include/llvm/LTO/ThinLTOCodeGenerator.h b/llvm/include/llvm/LTO/ThinLTOCodeGenerator.h
index 76dad3d..3407c82 100644
--- a/llvm/include/llvm/LTO/ThinLTOCodeGenerator.h
+++ b/llvm/include/llvm/LTO/ThinLTOCodeGenerator.h
@@ -169,6 +169,13 @@
TMBuilder.CGOptLevel = CGOptLevel;
}
+ /// Disable CodeGen, only run the stages till codegen and stop. The output
+ /// will be bitcode.
+ void disableCodeGen(bool Disable) { DisableCodeGen = Disable; }
+
+ /// Perform CodeGen only: disable all other stages.
+ void setCodeGenOnly(bool CGOnly) { CodeGenOnly = CGOnly; }
+
/**@}*/
/**
@@ -228,6 +235,14 @@
/// Path to a directory to save the temporary bitcode files.
std::string SaveTempsDir;
+
+ /// Flag to enable/disable CodeGen. When set to true, the process stops after
+ /// optimizations and a bitcode is produced.
+ bool DisableCodeGen;
+
+ /// Flag to indicate that only the CodeGen will be performed, no cross-module
+ /// importing or optimization.
+ bool CodeGenOnly;
};
}
#endif