mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 04:24:00 +00:00
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230290 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user