summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2015-02-24 00:45:56 +0000
committerManman Ren <manman.ren@gmail.com>2015-02-24 00:45:56 +0000
commit6487ce955a0227f24a0958997ca4785e6b343734 (patch)
tree1f1ad8070bad10d0f86c241619bdcd5aace5c50b /llvm/lib
parent8bc61df9f261f200039c30d053a205273e5c7906 (diff)
downloadbcm5719-llvm-6487ce955a0227f24a0958997ca4785e6b343734.tar.gz
bcm5719-llvm-6487ce955a0227f24a0958997ca4785e6b343734.zip
[LTO API] add lto_codegen_set_module to set the destination module.
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 to speed up debugging code generation passes and ld64 stuff after code generation. llvm linking a single bitcode file via lto_codegen_add_module will generate a different bitcode file from the single input. With the newly-added lto_codegen_set_module, we can make sure the destination module is the same as the input. lto_codegen_set_module will transfer the ownship of the module to code generator. rdar://19024554 llvm-svn: 230290
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/LTO/LTOCodeGenerator.cpp16
-rw-r--r--llvm/lib/Linker/LinkModules.cpp4
2 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 6e5bdaa97c7..1ba4159c9bf 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -141,6 +141,22 @@ bool LTOCodeGenerator::addModule(LTOModule *mod) {
return !ret;
}
+void LTOCodeGenerator::setModule(LTOModule *Mod) {
+ assert(&Mod->getModule().getContext() == &Context &&
+ "Expected module in same context");
+
+ // Delete the old merged module.
+ if (IRLinker.getModule())
+ IRLinker.deleteModule();
+ AsmUndefinedRefs.clear();
+
+ IRLinker.setModule(&Mod->getModule());
+
+ const std::vector<const char*> &Undefs = Mod->getAsmUndefinedRefs();
+ for (int I = 0, E = Undefs.size(); I != E; ++I)
+ AsmUndefinedRefs[Undefs[I]] = 1;
+}
+
void LTOCodeGenerator::setTargetOptions(TargetOptions options) {
Options = options;
}
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp
index b55fe483fb2..e6d9acc5098 100644
--- a/llvm/lib/Linker/LinkModules.cpp
+++ b/llvm/lib/Linker/LinkModules.cpp
@@ -1748,6 +1748,10 @@ bool Linker::linkInModule(Module *Src) {
return RetCode;
}
+void Linker::setModule(Module *Dst) {
+ init(Dst, DiagnosticHandler);
+}
+
//===----------------------------------------------------------------------===//
// LinkModules entrypoint.
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud