summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm-c/lto.h12
-rw-r--r--llvm/include/llvm/LTO/LTOCodeGenerator.h3
-rw-r--r--llvm/lib/LTO/LTOCodeGenerator.cpp3
-rw-r--r--llvm/tools/lto/lto.cpp5
-rw-r--r--llvm/tools/lto/lto.exports1
5 files changed, 22 insertions, 2 deletions
diff --git a/llvm/include/llvm-c/lto.h b/llvm/include/llvm-c/lto.h
index c6acdaddca5..2f3aac7ed87 100644
--- a/llvm/include/llvm-c/lto.h
+++ b/llvm/include/llvm-c/lto.h
@@ -40,7 +40,7 @@ typedef bool lto_bool_t;
* @{
*/
-#define LTO_API_VERSION 13
+#define LTO_API_VERSION 14
/**
* \since prior to LTO_API_VERSION=3
@@ -548,6 +548,16 @@ lto_codegen_debug_options(lto_code_gen_t cg, const char *);
extern void
lto_initialize_disassembler(void);
+/**
+ * Sets if we should run internalize pass during optimization and code
+ * generation.
+ *
+ * \since prior to LTO_API_VERSION=14
+ */
+extern void
+lto_codegen_set_should_internalize(lto_code_gen_t cg,
+ lto_bool_t ShouldInternalize);
+
#ifdef __cplusplus
}
#endif
diff --git a/llvm/include/llvm/LTO/LTOCodeGenerator.h b/llvm/include/llvm/LTO/LTOCodeGenerator.h
index a4aace41a72..ff3b71a1a0e 100644
--- a/llvm/include/llvm/LTO/LTOCodeGenerator.h
+++ b/llvm/include/llvm/LTO/LTOCodeGenerator.h
@@ -79,6 +79,8 @@ struct LTOCodeGenerator {
void setAttr(const char *mAttr) { MAttr = mAttr; }
void setOptLevel(unsigned optLevel) { OptLevel = optLevel; }
+ void setShouldInternalize(bool Value) { ShouldInternalize = Value; }
+
void addMustPreserveSymbol(const char *sym) { MustPreserveSymbols[sym] = 1; }
// To pass options to the driver and optimization passes. These options are
@@ -174,6 +176,7 @@ private:
lto_diagnostic_handler_t DiagHandler;
void *DiagContext;
LTOModule *OwnedModule;
+ bool ShouldInternalize;
};
}
#endif
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index b4a70119cc2..16718d7ce64 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -82,6 +82,7 @@ void LTOCodeGenerator::initialize() {
DiagHandler = nullptr;
DiagContext = nullptr;
OwnedModule = nullptr;
+ ShouldInternalize = true;
initializeLTOPasses();
}
@@ -464,7 +465,7 @@ static void accumulateAndSortLibcalls(std::vector<StringRef> &Libcalls,
}
void LTOCodeGenerator::applyScopeRestrictions() {
- if (ScopeRestrictionsDone)
+ if (ScopeRestrictionsDone || !ShouldInternalize)
return;
Module *mergedModule = IRLinker.getModule();
diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp
index cc4169fda99..e66a7786a14 100644
--- a/llvm/tools/lto/lto.cpp
+++ b/llvm/tools/lto/lto.cpp
@@ -333,3 +333,8 @@ void lto_codegen_debug_options(lto_code_gen_t cg, const char *opt) {
}
unsigned int lto_api_version() { return LTO_API_VERSION; }
+
+void lto_codegen_set_should_internalize(lto_code_gen_t cg,
+ bool ShouldInternalize) {
+ unwrap(cg)->setShouldInternalize(ShouldInternalize);
+}
diff --git a/llvm/tools/lto/lto.exports b/llvm/tools/lto/lto.exports
index 8729050123e..9145a6ff4dd 100644
--- a/llvm/tools/lto/lto.exports
+++ b/llvm/tools/lto/lto.exports
@@ -41,6 +41,7 @@ lto_codegen_set_cpu
lto_codegen_compile_to_file
lto_codegen_optimize
lto_codegen_compile_optimized
+lto_codegen_set_should_internalize
LLVMCreateDisasm
LLVMCreateDisasmCPU
LLVMDisasmDispose
OpenPOWER on IntegriCloud