summaryrefslogtreecommitdiffstats
path: root/lld/wasm/LTO.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/wasm/LTO.cpp')
-rw-r--r--lld/wasm/LTO.cpp148
1 files changed, 74 insertions, 74 deletions
diff --git a/lld/wasm/LTO.cpp b/lld/wasm/LTO.cpp
index 0c42e0e2123..fa48f4db7fd 100644
--- a/lld/wasm/LTO.cpp
+++ b/lld/wasm/LTO.cpp
@@ -40,127 +40,127 @@ using namespace lld;
using namespace lld::wasm;
static std::unique_ptr<lto::LTO> createLTO() {
- lto::Config C;
- C.Options = initTargetOptionsFromCodeGenFlags();
+ lto::Config c;
+ c.Options = initTargetOptionsFromCodeGenFlags();
// Always emit a section per function/data with LTO.
- C.Options.FunctionSections = true;
- C.Options.DataSections = true;
-
- C.DisableVerify = Config->DisableVerify;
- C.DiagHandler = diagnosticHandler;
- C.OptLevel = Config->LTOO;
- C.MAttrs = getMAttrs();
- C.CGOptLevel = args::getCGOptLevel(Config->LTOO);
-
- if (Config->Relocatable)
- C.RelocModel = None;
- else if (Config->Pic)
- C.RelocModel = Reloc::PIC_;
+ c.Options.FunctionSections = true;
+ c.Options.DataSections = true;
+
+ c.DisableVerify = config->disableVerify;
+ c.DiagHandler = diagnosticHandler;
+ c.OptLevel = config->ltoo;
+ c.MAttrs = getMAttrs();
+ c.CGOptLevel = args::getCGOptLevel(config->ltoo);
+
+ if (config->relocatable)
+ c.RelocModel = None;
+ else if (config->isPic)
+ c.RelocModel = Reloc::PIC_;
else
- C.RelocModel = Reloc::Static;
+ c.RelocModel = Reloc::Static;
- if (Config->SaveTemps)
- checkError(C.addSaveTemps(Config->OutputFile.str() + ".",
+ if (config->saveTemps)
+ checkError(c.addSaveTemps(config->outputFile.str() + ".",
/*UseInputModulePath*/ true));
- lto::ThinBackend Backend;
- if (Config->ThinLTOJobs != -1U)
- Backend = lto::createInProcessThinBackend(Config->ThinLTOJobs);
- return llvm::make_unique<lto::LTO>(std::move(C), Backend,
- Config->LTOPartitions);
+ lto::ThinBackend backend;
+ if (config->thinLTOJobs != -1U)
+ backend = lto::createInProcessThinBackend(config->thinLTOJobs);
+ return llvm::make_unique<lto::LTO>(std::move(c), backend,
+ config->ltoPartitions);
}
-BitcodeCompiler::BitcodeCompiler() : LTOObj(createLTO()) {}
+BitcodeCompiler::BitcodeCompiler() : ltoObj(createLTO()) {}
BitcodeCompiler::~BitcodeCompiler() = default;
-static void undefine(Symbol *S) {
- if (auto F = dyn_cast<DefinedFunction>(S))
- replaceSymbol<UndefinedFunction>(F, F->getName(), F->getName(),
- DefaultModule, 0,
- F->getFile(), F->Signature);
- else if (isa<DefinedData>(S))
- replaceSymbol<UndefinedData>(S, S->getName(), 0, S->getFile());
+static void undefine(Symbol *s) {
+ if (auto f = dyn_cast<DefinedFunction>(s))
+ replaceSymbol<UndefinedFunction>(f, f->getName(), f->getName(),
+ defaultModule, 0,
+ f->getFile(), f->signature);
+ else if (isa<DefinedData>(s))
+ replaceSymbol<UndefinedData>(s, s->getName(), 0, s->getFile());
else
llvm_unreachable("unexpected symbol kind");
}
-void BitcodeCompiler::add(BitcodeFile &F) {
- lto::InputFile &Obj = *F.Obj;
- unsigned SymNum = 0;
- ArrayRef<Symbol *> Syms = F.getSymbols();
- std::vector<lto::SymbolResolution> Resols(Syms.size());
+void BitcodeCompiler::add(BitcodeFile &f) {
+ lto::InputFile &obj = *f.obj;
+ unsigned symNum = 0;
+ ArrayRef<Symbol *> syms = f.getSymbols();
+ std::vector<lto::SymbolResolution> resols(syms.size());
// Provide a resolution to the LTO API for each symbol.
- for (const lto::InputFile::Symbol &ObjSym : Obj.symbols()) {
- Symbol *Sym = Syms[SymNum];
- lto::SymbolResolution &R = Resols[SymNum];
- ++SymNum;
+ for (const lto::InputFile::Symbol &objSym : obj.symbols()) {
+ Symbol *sym = syms[symNum];
+ lto::SymbolResolution &r = resols[symNum];
+ ++symNum;
// Ideally we shouldn't check for SF_Undefined but currently IRObjectFile
// reports two symbols for module ASM defined. Without this check, lld
// flags an undefined in IR with a definition in ASM as prevailing.
// Once IRObjectFile is fixed to report only one symbol this hack can
// be removed.
- R.Prevailing = !ObjSym.isUndefined() && Sym->getFile() == &F;
- R.VisibleToRegularObj = Config->Relocatable || Sym->IsUsedInRegularObj ||
- (R.Prevailing && Sym->isExported());
- if (R.Prevailing)
- undefine(Sym);
+ r.Prevailing = !objSym.isUndefined() && sym->getFile() == &f;
+ r.VisibleToRegularObj = config->relocatable || sym->isUsedInRegularObj ||
+ (r.Prevailing && sym->isExported());
+ if (r.Prevailing)
+ undefine(sym);
// We tell LTO to not apply interprocedural optimization for wrapped
// (with --wrap) symbols because otherwise LTO would inline them while
// their values are still not final.
- R.LinkerRedefined = !Sym->CanInline;
+ r.LinkerRedefined = !sym->canInline;
}
- checkError(LTOObj->add(std::move(F.Obj), Resols));
+ checkError(ltoObj->add(std::move(f.obj), resols));
}
// Merge all the bitcode files we have seen, codegen the result
// and return the resulting objects.
std::vector<StringRef> BitcodeCompiler::compile() {
- unsigned MaxTasks = LTOObj->getMaxTasks();
- Buf.resize(MaxTasks);
- Files.resize(MaxTasks);
+ unsigned maxTasks = ltoObj->getMaxTasks();
+ buf.resize(maxTasks);
+ files.resize(maxTasks);
// The --thinlto-cache-dir option specifies the path to a directory in which
// to cache native object files for ThinLTO incremental builds. If a path was
// specified, configure LTO to use it as the cache directory.
- lto::NativeObjectCache Cache;
- if (!Config->ThinLTOCacheDir.empty())
- Cache = check(
- lto::localCache(Config->ThinLTOCacheDir,
- [&](size_t Task, std::unique_ptr<MemoryBuffer> MB) {
- Files[Task] = std::move(MB);
+ lto::NativeObjectCache cache;
+ if (!config->thinLTOCacheDir.empty())
+ cache = check(
+ lto::localCache(config->thinLTOCacheDir,
+ [&](size_t task, std::unique_ptr<MemoryBuffer> mb) {
+ files[task] = std::move(mb);
}));
- checkError(LTOObj->run(
- [&](size_t Task) {
+ checkError(ltoObj->run(
+ [&](size_t task) {
return llvm::make_unique<lto::NativeObjectStream>(
- llvm::make_unique<raw_svector_ostream>(Buf[Task]));
+ llvm::make_unique<raw_svector_ostream>(buf[task]));
},
- Cache));
+ cache));
- if (!Config->ThinLTOCacheDir.empty())
- pruneCache(Config->ThinLTOCacheDir, Config->ThinLTOCachePolicy);
+ if (!config->thinLTOCacheDir.empty())
+ pruneCache(config->thinLTOCacheDir, config->thinLTOCachePolicy);
- std::vector<StringRef> Ret;
- for (unsigned I = 0; I != MaxTasks; ++I) {
- if (Buf[I].empty())
+ std::vector<StringRef> ret;
+ for (unsigned i = 0; i != maxTasks; ++i) {
+ if (buf[i].empty())
continue;
- if (Config->SaveTemps) {
- if (I == 0)
- saveBuffer(Buf[I], Config->OutputFile + ".lto.o");
+ if (config->saveTemps) {
+ if (i == 0)
+ saveBuffer(buf[i], config->outputFile + ".lto.o");
else
- saveBuffer(Buf[I], Config->OutputFile + Twine(I) + ".lto.o");
+ saveBuffer(buf[i], config->outputFile + Twine(i) + ".lto.o");
}
- Ret.emplace_back(Buf[I].data(), Buf[I].size());
+ ret.emplace_back(buf[i].data(), buf[i].size());
}
- for (std::unique_ptr<MemoryBuffer> &File : Files)
- if (File)
- Ret.push_back(File->getBuffer());
+ for (std::unique_ptr<MemoryBuffer> &file : files)
+ if (file)
+ ret.push_back(file->getBuffer());
- return Ret;
+ return ret;
}
OpenPOWER on IntegriCloud