[LTOCodeGenerator] Reduce code duplication. NFCI.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279514 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Davide Italiano 2016-08-23 12:32:57 +00:00
parent 9cbe8af733
commit 5bf89a1581
2 changed files with 9 additions and 8 deletions

View File

@ -77,6 +77,7 @@ struct LTOCodeGenerator {
/// Resets \a HasVerifiedInput.
void setModule(std::unique_ptr<LTOModule> M);
void setAsmUndefinedRefs(struct LTOModule *);
void setTargetOptions(const TargetOptions &Options);
void setDebugInfo(lto_debug_model);
void setCodePICModel(Optional<Reloc::Model> Model) { RelocModel = Model; }

View File

@ -130,15 +130,18 @@ void LTOCodeGenerator::initializeLTOPasses() {
initializeCFGSimplifyPassPass(R);
}
void LTOCodeGenerator::setAsmUndefinedRefs(LTOModule *Mod) {
const std::vector<const char *> &undefs = Mod->getAsmUndefinedRefs();
for (int i = 0, e = undefs.size(); i != e; ++i)
AsmUndefinedRefs[undefs[i]] = 1;
}
bool LTOCodeGenerator::addModule(LTOModule *Mod) {
assert(&Mod->getModule().getContext() == &Context &&
"Expected module in same context");
bool ret = TheLinker->linkInModule(Mod->takeModule());
const std::vector<const char *> &undefs = Mod->getAsmUndefinedRefs();
for (int i = 0, e = undefs.size(); i != e; ++i)
AsmUndefinedRefs[undefs[i]] = 1;
setAsmUndefinedRefs(Mod);
// We've just changed the input, so let's make sure we verify it.
HasVerifiedInput = false;
@ -154,10 +157,7 @@ void LTOCodeGenerator::setModule(std::unique_ptr<LTOModule> Mod) {
MergedModule = Mod->takeModule();
TheLinker = make_unique<Linker>(*MergedModule);
const std::vector<const char*> &Undefs = Mod->getAsmUndefinedRefs();
for (int I = 0, E = Undefs.size(); I != E; ++I)
AsmUndefinedRefs[Undefs[I]] = 1;
setAsmUndefinedRefs(&*Mod);
// We've just changed the input, so let's make sure we verify it.
HasVerifiedInput = false;