summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-lto/llvm-lto.cpp
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/tools/llvm-lto/llvm-lto.cpp
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/tools/llvm-lto/llvm-lto.cpp')
-rw-r--r--llvm/tools/llvm-lto/llvm-lto.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp
index 92bac8351fd..32b31343411 100644
--- a/llvm/tools/llvm-lto/llvm-lto.cpp
+++ b/llvm/tools/llvm-lto/llvm-lto.cpp
@@ -69,6 +69,10 @@ static cl::opt<bool> ListSymbolsOnly(
"list-symbols-only", cl::init(false),
cl::desc("Instead of running LTO, list the symbols in each IR file"));
+static cl::opt<bool> SetMergedModule(
+ "set-merged-module", cl::init(false),
+ cl::desc("Use the first input module as the merged module"));
+
namespace {
struct ModuleInfo {
std::vector<bool> CanBeHidden;
@@ -194,15 +198,22 @@ int main(int argc, char **argv) {
return 1;
}
- if (!CodeGen.addModule(Module.get()))
+ LTOModule *LTOMod = Module.get();
+
+ // We use the first input module as the destination module when
+ // SetMergedModule is true.
+ if (SetMergedModule && i == BaseArg) {
+ // Transfer ownership to the code generator.
+ CodeGen.setModule(Module.release());
+ } else if (!CodeGen.addModule(Module.get()))
return 1;
- unsigned NumSyms = Module->getSymbolCount();
+ unsigned NumSyms = LTOMod->getSymbolCount();
for (unsigned I = 0; I < NumSyms; ++I) {
- StringRef Name = Module->getSymbolName(I);
+ StringRef Name = LTOMod->getSymbolName(I);
if (!DSOSymbolsSet.count(Name))
continue;
- lto_symbol_attributes Attrs = Module->getSymbolAttributes(I);
+ lto_symbol_attributes Attrs = LTOMod->getSymbolAttributes(I);
unsigned Scope = Attrs & LTO_SYMBOL_SCOPE_MASK;
if (Scope != LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN)
KeptDSOSyms.push_back(Name);
OpenPOWER on IntegriCloud