LTOCodeGenerator::LTOCodeGenerator(LLVMContext &Context)
: Context(Context), MergedModule(new Module("ld-temp.o", Context)),
- IRLinker(new Linker(*MergedModule)) {
+ TheLinker(new Linker(*MergedModule)) {
initializeLTOPasses();
}
assert(&Mod->getModule().getContext() == &Context &&
"Expected module in same context");
- bool ret = IRLinker->linkInModule(Mod->takeModule());
+ 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.clear();
MergedModule = Mod->takeModule();
- IRLinker = make_unique<Linker>(*MergedModule);
+ TheLinker = make_unique<Linker>(*MergedModule);
const std::vector<const char*> &Undefs = Mod->getAsmUndefinedRefs();
for (int I = 0, E = Undefs.size(); I != E; ++I)
void LinkDiagnosticInfo::print(DiagnosticPrinter &DP) const { DP << Msg; }
//===----------------------------------------------------------------------===//
-// ModuleLinker implementation.
+// IRLinker implementation.
//===----------------------------------------------------------------------===//
namespace {
/// speeds up linking for modules with many/ lazily linked functions of which
/// few get used.
class GlobalValueMaterializer final : public ValueMaterializer {
- IRLinker *ModLinker;
+ IRLinker *TheIRLinker;
public:
- GlobalValueMaterializer(IRLinker *ModLinker) : ModLinker(ModLinker) {}
+ GlobalValueMaterializer(IRLinker *TheIRLinker) : TheIRLinker(TheIRLinker) {}
Value *materializeDeclFor(Value *V) override;
void materializeInitFor(GlobalValue *New, GlobalValue *Old) override;
Metadata *mapTemporaryMetadata(Metadata *MD) override;
};
class LocalValueMaterializer final : public ValueMaterializer {
- IRLinker *ModLinker;
+ IRLinker *TheIRLinker;
public:
- LocalValueMaterializer(IRLinker *ModLinker) : ModLinker(ModLinker) {}
+ LocalValueMaterializer(IRLinker *TheIRLinker) : TheIRLinker(TheIRLinker) {}
Value *materializeDeclFor(Value *V) override;
void materializeInitFor(GlobalValue *New, GlobalValue *Old) override;
Metadata *mapTemporaryMetadata(Metadata *MD) override;
}
Value *GlobalValueMaterializer::materializeDeclFor(Value *V) {
- return ModLinker->materializeDeclFor(V, false);
+ return TheIRLinker->materializeDeclFor(V, false);
}
void GlobalValueMaterializer::materializeInitFor(GlobalValue *New,
GlobalValue *Old) {
- ModLinker->materializeInitFor(New, Old, false);
+ TheIRLinker->materializeInitFor(New, Old, false);
}
Metadata *GlobalValueMaterializer::mapTemporaryMetadata(Metadata *MD) {
- return ModLinker->mapTemporaryMetadata(MD);
+ return TheIRLinker->mapTemporaryMetadata(MD);
}
void GlobalValueMaterializer::replaceTemporaryMetadata(const Metadata *OrigMD,
Metadata *NewMD) {
- ModLinker->replaceTemporaryMetadata(OrigMD, NewMD);
+ TheIRLinker->replaceTemporaryMetadata(OrigMD, NewMD);
}
bool GlobalValueMaterializer::isMetadataNeeded(Metadata *MD) {
- return ModLinker->isMetadataNeeded(MD);
+ return TheIRLinker->isMetadataNeeded(MD);
}
Value *LocalValueMaterializer::materializeDeclFor(Value *V) {
- return ModLinker->materializeDeclFor(V, true);
+ return TheIRLinker->materializeDeclFor(V, true);
}
void LocalValueMaterializer::materializeInitFor(GlobalValue *New,
GlobalValue *Old) {
- ModLinker->materializeInitFor(New, Old, true);
+ TheIRLinker->materializeInitFor(New, Old, true);
}
Metadata *LocalValueMaterializer::mapTemporaryMetadata(Metadata *MD) {
- return ModLinker->mapTemporaryMetadata(MD);
+ return TheIRLinker->mapTemporaryMetadata(MD);
}
void LocalValueMaterializer::replaceTemporaryMetadata(const Metadata *OrigMD,
Metadata *NewMD) {
- ModLinker->replaceTemporaryMetadata(OrigMD, NewMD);
+ TheIRLinker->replaceTemporaryMetadata(OrigMD, NewMD);
}
bool LocalValueMaterializer::isMetadataNeeded(Metadata *MD) {
- return ModLinker->isMetadataNeeded(MD);
+ return TheIRLinker->isMetadataNeeded(MD);
}
Value *IRLinker::materializeDeclFor(Value *V, bool ForAlias) {
std::function<void(GlobalValue &, ValueAdder Add)> AddLazyFor,
DenseMap<unsigned, MDNode *> *ValIDToTempMDMap,
bool IsMetadataLinkingPostpass) {
- IRLinker TheLinker(Composite, IdentifiedStructTypes, Src, ValuesToLink,
- AddLazyFor, ValIDToTempMDMap, IsMetadataLinkingPostpass);
- bool RetCode = TheLinker.run();
+ IRLinker TheIRLinker(Composite, IdentifiedStructTypes, Src, ValuesToLink,
+ AddLazyFor, ValIDToTempMDMap, IsMetadataLinkingPostpass);
+ bool RetCode = TheIRLinker.run();
Composite.dropTriviallyDeadConstantArrays();
return RetCode;
}
const FunctionInfoIndex *Index,
DenseSet<const GlobalValue *> *FunctionsToImport,
DenseMap<unsigned, MDNode *> *ValIDToTempMDMap) {
- ModuleLinker TheLinker(Mover, *Src, Flags, Index, FunctionsToImport,
+ ModuleLinker ModLinker(Mover, *Src, Flags, Index, FunctionsToImport,
ValIDToTempMDMap);
- return TheLinker.run();
+ return ModLinker.run();
}
bool Linker::linkInModuleForCAPI(Module &Src) {
- ModuleLinker TheLinker(Mover, Src, 0, nullptr, nullptr);
- return TheLinker.run();
+ ModuleLinker ModLinker(Mover, Src, 0, nullptr, nullptr);
+ return ModLinker.run();
}
bool Linker::linkInMetadata(Module &Src,