[llvm] r235211 - [LTO API] add lto_codegen_set_should_internalize.
Manman Ren
manman.ren at gmail.com
Fri Apr 17 10:10:09 PDT 2015
Author: mren
Date: Fri Apr 17 12:10:09 2015
New Revision: 235211
URL: http://llvm.org/viewvc/llvm-project?rev=235211&view=rev
Log:
[LTO API] add lto_codegen_set_should_internalize.
When debugging LTO issues with ld64, we use -save-temps to save the merged
optimized bitcode file, then invoke ld64 again on the single bitcode file.
The saved bitcode file is already internalized, so we can call
lto_codegen_set_should_internalize and skip running internalization again.
rdar://20227235
Modified:
llvm/trunk/include/llvm-c/lto.h
llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h
llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
llvm/trunk/tools/lto/lto.cpp
llvm/trunk/tools/lto/lto.exports
Modified: llvm/trunk/include/llvm-c/lto.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/lto.h?rev=235211&r1=235210&r2=235211&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/lto.h (original)
+++ llvm/trunk/include/llvm-c/lto.h Fri Apr 17 12:10:09 2015
@@ -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
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
Modified: llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h?rev=235211&r1=235210&r2=235211&view=diff
==============================================================================
--- llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h (original)
+++ llvm/trunk/include/llvm/LTO/LTOCodeGenerator.h Fri Apr 17 12:10:09 2015
@@ -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
Modified: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCodeGenerator.cpp?rev=235211&r1=235210&r2=235211&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp Fri Apr 17 12:10:09 2015
@@ -82,6 +82,7 @@ void LTOCodeGenerator::initialize() {
DiagHandler = nullptr;
DiagContext = nullptr;
OwnedModule = nullptr;
+ ShouldInternalize = true;
initializeLTOPasses();
}
@@ -464,7 +465,7 @@ static void accumulateAndSortLibcalls(st
}
void LTOCodeGenerator::applyScopeRestrictions() {
- if (ScopeRestrictionsDone)
+ if (ScopeRestrictionsDone || !ShouldInternalize)
return;
Module *mergedModule = IRLinker.getModule();
Modified: llvm/trunk/tools/lto/lto.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.cpp?rev=235211&r1=235210&r2=235211&view=diff
==============================================================================
--- llvm/trunk/tools/lto/lto.cpp (original)
+++ llvm/trunk/tools/lto/lto.cpp Fri Apr 17 12:10:09 2015
@@ -333,3 +333,8 @@ void lto_codegen_debug_options(lto_code_
}
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);
+}
Modified: llvm/trunk/tools/lto/lto.exports
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.exports?rev=235211&r1=235210&r2=235211&view=diff
==============================================================================
--- llvm/trunk/tools/lto/lto.exports (original)
+++ llvm/trunk/tools/lto/lto.exports Fri Apr 17 12:10:09 2015
@@ -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
More information about the llvm-commits
mailing list