Skip to content

Commit 4639a9a

Browse files
committed
[lld-link] Replace log(...) with Log
1 parent 87c21bf commit 4639a9a

File tree

7 files changed

+42
-38
lines changed

7 files changed

+42
-38
lines changed

lld/COFF/DebugTypes.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ void TpiSource::remapRecord(MutableArrayRef<uint8_t> rec,
241241
uint16_t kind =
242242
reinterpret_cast<const RecordPrefix *>(rec.data())->RecordKind;
243243
StringRef fname = file ? file->getName() : "<unknown PDB>";
244-
log("failed to remap type index in record of kind 0x" +
245-
utohexstr(kind) + " in " + fname + " with bad " +
246-
(ref.Kind == TiRefKind::IndexRef ? "item" : "type") +
247-
" index 0x" + utohexstr(ti.getIndex()));
244+
Log(ctx) << "failed to remap type index in record of kind 0x"
245+
<< utohexstr(kind) << " in " << fname << " with bad "
246+
<< (ref.Kind == TiRefKind::IndexRef ? "item" : "type")
247+
<< " index 0x" << utohexstr(ti.getIndex());
248248
}
249249
ti = TypeIndex(SimpleTypeKind::NotTranslated);
250250
continue;
@@ -1137,9 +1137,10 @@ void TypeMerger::mergeTypesWithGHash() {
11371137
entries.push_back(cell);
11381138
}
11391139
parallelSort(entries, std::less<GHashCell>());
1140-
log(formatv("ghash table load factor: {0:p} (size {1} / capacity {2})\n",
1141-
tableSize ? double(entries.size()) / tableSize : 0,
1142-
entries.size(), tableSize));
1140+
Log(ctx) << formatv(
1141+
"ghash table load factor: {0:p} (size {1} / capacity {2})\n",
1142+
tableSize ? double(entries.size()) / tableSize : 0, entries.size(),
1143+
tableSize);
11431144

11441145
// Find out how many type and item indices there are.
11451146
auto mid = llvm::lower_bound(entries, GHashCell(true, 0, 0));
@@ -1148,8 +1149,8 @@ void TypeMerger::mergeTypesWithGHash() {
11481149
"midpoint is not midpoint");
11491150
uint32_t numTypes = std::distance(entries.begin(), mid);
11501151
uint32_t numItems = std::distance(mid, entries.end());
1151-
log("Tpi record count: " + Twine(numTypes));
1152-
log("Ipi record count: " + Twine(numItems));
1152+
Log(ctx) << "Tpi record count: " << Twine(numTypes);
1153+
Log(ctx) << "Ipi record count: " << Twine(numItems);
11531154

11541155
// Make a list of the "unique" type records to merge for each tpi source. Type
11551156
// merging will skip indices not on this list. Store the destination PDB type

lld/COFF/Driver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ StringRef LinkerDriver::mangleMaybe(Symbol *s) {
779779

780780
// If we find a similar mangled symbol, make this an alias to it and return
781781
// its name.
782-
log(unmangled->getName() + " aliased to " + mangled->getName());
782+
Log(ctx) << unmangled->getName() << " aliased to " << mangled->getName();
783783
unmangled->setWeakAlias(ctx.symtab.addUndefined(mangled->getName()));
784784
return mangled->getName();
785785
}
@@ -2419,7 +2419,7 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
24192419
if (s.empty())
24202420
fatal("entry point must be defined");
24212421
config->entry = addUndefined(s, true);
2422-
log("Entry name inferred: " + s);
2422+
Log(ctx) << "Entry name inferred: " << s;
24232423
}
24242424
}
24252425
}

lld/COFF/ICF.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,16 +314,16 @@ void ICF::run() {
314314
[&](size_t begin, size_t end) { segregate(begin, end, false); });
315315
} while (repeat);
316316

317-
log("ICF needed " + Twine(cnt) + " iterations");
317+
Log(ctx) << "ICF needed " << Twine(cnt) << " iterations";
318318

319319
// Merge sections in the same classes.
320320
forEachClass([&](size_t begin, size_t end) {
321321
if (end - begin == 1)
322322
return;
323323

324-
log("Selected " + chunks[begin]->getDebugName());
324+
Log(ctx) << "Selected " << chunks[begin]->getDebugName();
325325
for (size_t i = begin + 1; i < end; ++i) {
326-
log(" Removed " + chunks[i]->getDebugName());
326+
Log(ctx) << " Removed " << chunks[i]->getDebugName();
327327
chunks[begin]->replace(chunks[i]);
328328
}
329329
});

lld/COFF/InputFiles.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,8 @@ void ObjFile::initializeSymbols() {
518518
}
519519
if (sparseChunks[sym.getSectionNumber()] == pendingComdat) {
520520
StringRef name = check(coffObj->getSymbolName(sym));
521-
log("comdat section " + name +
522-
" without leader and unassociated, discarding");
521+
Log(ctx) << "comdat section " << name
522+
<< " without leader and unassociated, discarding";
523523
continue;
524524
}
525525
symbols[i] = createRegular(sym);
@@ -620,10 +620,9 @@ void ObjFile::handleComdatSelection(
620620
// seems better though.
621621
// (This behavior matches ModuleLinker::getComdatResult().)
622622
if (selection != leaderSelection) {
623-
log(("conflicting comdat type for " + toString(ctx, *leader) + ": " +
624-
Twine((int)leaderSelection) + " in " + toString(leader->getFile()) +
625-
" and " + Twine((int)selection) + " in " + toString(this))
626-
.str());
623+
Log(ctx) << "conflicting comdat type for " << toString(ctx, *leader) << ": "
624+
<< (int)leaderSelection << " in " << leader->getFile() << " and "
625+
<< (int)selection << " in " << this;
627626
ctx.symtab.reportDuplicate(leader, this);
628627
return;
629628
}

lld/COFF/PDB.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,8 @@ void PDBLinker::writeSymbolRecord(SectionChunk *debugChunk,
569569
// Re-map all the type index references.
570570
TpiSource *source = debugChunk->file->debugTypesObj;
571571
if (!source->remapTypesInSymbolRecord(recordBytes)) {
572-
log("ignoring unknown symbol record with kind 0x" + utohexstr(sym.kind()));
572+
Log(ctx) << "ignoring unknown symbol record with kind 0x"
573+
<< utohexstr(sym.kind());
573574
replaceWithSkipRecord(recordBytes);
574575
}
575576

lld/COFF/SymbolTable.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ static bool compatibleMachineType(COFFLinkerContext &ctx, MachineTypes mt) {
5454
}
5555

5656
void SymbolTable::addFile(InputFile *file) {
57-
log("Reading " + toString(file));
57+
Log(ctx) << "Reading " << toString(file);
5858
if (file->lazy) {
5959
if (auto *f = dyn_cast<BitcodeFile>(file))
6060
f->parseLazy();
@@ -320,8 +320,8 @@ void SymbolTable::loadMinGWSymbols() {
320320
if (newName != origName && (l = find(newName)) != nullptr) {
321321
// If we found a symbol and it is lazy; load it.
322322
if (l->isLazy() && !l->pendingArchiveLoad) {
323-
log("Loading lazy " + l->getName() + " from " +
324-
l->getFile()->getName() + " for stdcall fixup");
323+
Log(ctx) << "Loading lazy " << l->getName() << " from "
324+
<< l->getFile()->getName() << " for stdcall fixup";
325325
forceLazy(l);
326326
}
327327
// If it's lazy or already defined, hook it up as weak alias.
@@ -330,7 +330,8 @@ void SymbolTable::loadMinGWSymbols() {
330330
Warn(ctx) << "Resolving " << origName << " by linking to "
331331
<< newName;
332332
else
333-
log("Resolving " + origName + " by linking to " + newName);
333+
Log(ctx) << "Resolving " << origName << " by linking to "
334+
<< newName;
334335
undef->setWeakAlias(l);
335336
continue;
336337
}
@@ -346,8 +347,8 @@ void SymbolTable::loadMinGWSymbols() {
346347
if (!l || l->pendingArchiveLoad || !l->isLazy())
347348
continue;
348349

349-
log("Loading lazy " + l->getName() + " from " + l->getFile()->getName() +
350-
" for automatic import");
350+
Log(ctx) << "Loading lazy " << l->getName() << " from "
351+
<< l->getFile()->getName() << " for automatic import";
351352
forceLazy(l);
352353
}
353354
}
@@ -372,12 +373,12 @@ bool SymbolTable::handleMinGWAutomaticImport(Symbol *sym, StringRef name) {
372373
// reference itself to point at the IAT entry.
373374
size_t impSize = 0;
374375
if (isa<DefinedImportData>(imp)) {
375-
log("Automatically importing " + name + " from " +
376-
cast<DefinedImportData>(imp)->getDLLName());
376+
Log(ctx) << "Automatically importing " << name << " from "
377+
<< cast<DefinedImportData>(imp)->getDLLName();
377378
impSize = sizeof(DefinedImportData);
378379
} else if (isa<DefinedRegular>(imp)) {
379-
log("Automatically importing " + name + " from " +
380-
toString(cast<DefinedRegular>(imp)->file));
380+
Log(ctx) << "Automatically importing " << name << " from "
381+
<< toString(cast<DefinedRegular>(imp)->file);
381382
impSize = sizeof(DefinedRegular);
382383
} else {
383384
Warn(ctx) << "unable to automatically import " << name << " from "
@@ -398,7 +399,7 @@ bool SymbolTable::handleMinGWAutomaticImport(Symbol *sym, StringRef name) {
398399
if (refptr && refptr->getChunk()->getSize() == ctx.config.wordsize) {
399400
SectionChunk *sc = dyn_cast_or_null<SectionChunk>(refptr->getChunk());
400401
if (sc && sc->getRelocs().size() == 1 && *sc->symbols().begin() == sym) {
401-
log("Replacing .refptr." + name + " with " + imp->getName());
402+
Log(ctx) << "Replacing .refptr." << name << " with " << imp->getName();
402403
refptr->getChunk()->live = false;
403404
refptr->replaceKeepingName(imp, impSize);
404405
}

lld/COFF/Writer.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,9 @@ void Writer::finalizeAddresses() {
670670
}
671671
if (rangesOk) {
672672
if (pass > 0)
673-
log("Added " + Twine(numChunks - origNumChunks) + " thunks with " +
674-
"margin " + Twine(margin) + " in " + Twine(pass) + " passes");
673+
Log(ctx) << "Added " << Twine(numChunks - origNumChunks)
674+
<< " thunks with " << "margin " << Twine(margin) << " in "
675+
<< Twine(pass) << " passes";
675676
return;
676677
}
677678

@@ -1116,7 +1117,7 @@ void Writer::createSections() {
11161117
// special case for all architectures.
11171118
outChars = data | r;
11181119

1119-
log("Processing section " + pSec->name + " -> " + name);
1120+
Log(ctx) << "Processing section " << pSec->name << " -> " << name;
11201121

11211122
sortCRTSectionChunks(pSec->chunks);
11221123
}
@@ -2221,7 +2222,8 @@ void Writer::createRuntimePseudoRelocs() {
22212222
}
22222223

22232224
if (!rels.empty()) {
2224-
log("Writing " + Twine(rels.size()) + " runtime pseudo relocations");
2225+
Log(ctx) << "Writing " << Twine(rels.size())
2226+
<< " runtime pseudo relocations";
22252227
const char *symbolName = "_pei386_runtime_relocator";
22262228
Symbol *relocator = ctx.symtab.findUnderscore(symbolName);
22272229
if (!relocator)
@@ -2496,8 +2498,8 @@ void Writer::sortCRTSectionChunks(std::vector<Chunk *> &chunks) {
24962498
if (ctx.config.verbose) {
24972499
for (auto &c : chunks) {
24982500
auto sc = dyn_cast<SectionChunk>(c);
2499-
log(" " + sc->file->mb.getBufferIdentifier().str() +
2500-
", SectionID: " + Twine(sc->getSectionNumber()));
2501+
Log(ctx) << " " << sc->file->mb.getBufferIdentifier().str()
2502+
<< ", SectionID: " << Twine(sc->getSectionNumber());
25012503
}
25022504
}
25032505
}

0 commit comments

Comments
 (0)