Skip to content

Commit 1cd6275

Browse files
committed
[ELF] Remove unneeded Twine in ELFSyncStream
1 parent c4dc5ed commit 1cd6275

13 files changed

+48
-53
lines changed

lld/ELF/Arch/ARM.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,8 @@ void ARM::encodeAluGroup(uint8_t *loc, const Relocation &rel, uint64_t val,
557557
rot = (lz + 8) << 7;
558558
}
559559
if (check && imm > 0xff)
560-
Err(ctx) << getErrorLoc(ctx, loc) << "unencodeable immediate "
561-
<< Twine(val).str() << " for relocation " << rel.type;
560+
Err(ctx) << getErrorLoc(ctx, loc) << "unencodeable immediate " << val
561+
<< " for relocation " << rel.type;
562562
write32(ctx, loc,
563563
(read32(ctx, loc) & 0xff3ff000) | opcode | rot | (imm & 0xff));
564564
}
@@ -1238,8 +1238,8 @@ template <class ELFT> void ObjFile<ELFT>::importCmseSymbols() {
12381238

12391239
if (eSym.st_size != ACLESESYM_SIZE) {
12401240
Warn(ctx) << "CMSE symbol '" << sym->getName() << "' in import library '"
1241-
<< this << "' does not have correct size of "
1242-
<< Twine(ACLESESYM_SIZE) << " bytes";
1241+
<< this << "' does not have correct size of " << ACLESESYM_SIZE
1242+
<< " bytes";
12431243
}
12441244

12451245
ctx.symtab->cmseImportLib[sym->getName()] = sym;

lld/ELF/Arch/LoongArch.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -775,8 +775,8 @@ static bool relax(Ctx &ctx, InputSection &sec) {
775775
if (LLVM_UNLIKELY(static_cast<int32_t>(remove) < 0)) {
776776
Err(ctx) << getErrorLoc(ctx, (const uint8_t *)loc)
777777
<< "insufficient padding bytes for " << r.type << ": "
778-
<< Twine(allBytes) << " bytes available for "
779-
<< "requested alignment of " << Twine(align) << " bytes";
778+
<< allBytes << " bytes available for "
779+
<< "requested alignment of " << align << " bytes";
780780
remove = 0;
781781
}
782782
break;
@@ -807,7 +807,7 @@ static bool relax(Ctx &ctx, InputSection &sec) {
807807
}
808808
// Inform assignAddresses that the size has changed.
809809
if (!isUInt<32>(delta))
810-
Fatal(ctx) << "section size decrease is too large: " << Twine(delta);
810+
Fatal(ctx) << "section size decrease is too large: " << delta;
811811
sec.bytesDropped = delta;
812812
return changed;
813813
}
@@ -838,7 +838,7 @@ bool LoongArch::relaxOnce(int pass) const {
838838
}
839839

840840
void LoongArch::finalizeRelax(int passes) const {
841-
Log(ctx) << "relaxation passes: " << Twine(passes);
841+
Log(ctx) << "relaxation passes: " << passes;
842842
SmallVector<InputSection *, 0> storage;
843843
for (OutputSection *osec : ctx.outputSections) {
844844
if (!(osec->flags & SHF_EXECINSTR))

lld/ELF/Arch/Mips.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ calculateMipsRelChain(Ctx &ctx, uint8_t *loc, uint32_t type, uint64_t val) {
503503
if (type2 == R_MIPS_SUB && (type3 == R_MIPS_HI16 || type3 == R_MIPS_LO16))
504504
return std::make_pair(type3, -val);
505505
Err(ctx) << getErrorLoc(ctx, loc) << "unsupported relocations combination "
506-
<< Twine(type);
506+
<< type;
507507
return std::make_pair(type & 0xff, val);
508508
}
509509

lld/ELF/Arch/RISCV.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,9 @@ void RISCV::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
658658
auto val = rel.sym->getVA(ctx, rel.addend) -
659659
rel1.sym->getVA(ctx, rel1.addend);
660660
if (overwriteULEB128(loc, val) >= 0x80)
661-
Err(ctx) << sec.getLocation(rel.offset) << ": ULEB128 value "
662-
<< Twine(val) << " exceeds available space; references '"
663-
<< rel.sym << "'";
661+
Err(ctx) << sec.getLocation(rel.offset) << ": ULEB128 value " << val
662+
<< " exceeds available space; references '" << rel.sym
663+
<< "'";
664664
++i;
665665
continue;
666666
}
@@ -832,10 +832,10 @@ static bool relax(Ctx &ctx, InputSection &sec) {
832832
if (LLVM_UNLIKELY(static_cast<int32_t>(remove) < 0)) {
833833
Err(ctx) << getErrorLoc(ctx, (const uint8_t *)loc)
834834
<< "insufficient padding bytes for " << r.type << ": "
835-
<< Twine(r.addend)
835+
<< r.addend
836836
<< " bytes available "
837837
"for requested alignment of "
838-
<< Twine(align) << " bytes";
838+
<< align << " bytes";
839839
remove = 0;
840840
}
841841
break;
@@ -899,7 +899,7 @@ static bool relax(Ctx &ctx, InputSection &sec) {
899899
}
900900
// Inform assignAddresses that the size has changed.
901901
if (!isUInt<32>(delta))
902-
Fatal(ctx) << "section size decrease is too large: " << Twine(delta);
902+
Fatal(ctx) << "section size decrease is too large: " << delta;
903903
sec.bytesDropped = delta;
904904
return changed;
905905
}
@@ -932,7 +932,7 @@ bool RISCV::relaxOnce(int pass) const {
932932

933933
void RISCV::finalizeRelax(int passes) const {
934934
llvm::TimeTraceScope timeScope("Finalize RISC-V relaxation");
935-
Log(ctx) << "relaxation passes: " << Twine(passes);
935+
Log(ctx) << "relaxation passes: " << passes;
936936
SmallVector<InputSection *, 0> storage;
937937
for (OutputSection *osec : ctx.outputSections) {
938938
if (!(osec->flags & SHF_EXECINSTR))
@@ -1095,10 +1095,9 @@ static void mergeAtomic(Ctx &ctx, DenseMap<unsigned, unsigned>::iterator it,
10951095

10961096
auto reportAbiError = [&]() {
10971097
Err(ctx) << "atomic abi mismatch for " << oldSection->name << "\n>>> "
1098-
<< oldSection
1099-
<< ": atomic_abi=" << Twine(static_cast<unsigned>(oldTag))
1098+
<< oldSection << ": atomic_abi=" << static_cast<unsigned>(oldTag)
11001099
<< "\n>>> " << newSection
1101-
<< ": atomic_abi=" << Twine(static_cast<unsigned>(newTag));
1100+
<< ": atomic_abi=" << static_cast<unsigned>(newTag);
11021101
};
11031102

11041103
auto reportUnknownAbiError = [&](const InputSectionBase *section,
@@ -1111,7 +1110,7 @@ static void mergeAtomic(Ctx &ctx, DenseMap<unsigned, unsigned>::iterator it,
11111110
return;
11121111
};
11131112
Err(ctx) << "unknown atomic abi for " << section->name << "\n>>> "
1114-
<< section << ": atomic_abi=" << Twine(static_cast<unsigned>(tag));
1113+
<< section << ": atomic_abi=" << static_cast<unsigned>(tag);
11151114
};
11161115
switch (oldTag) {
11171116
case RISCVAtomicAbiTag::UNKNOWN:

lld/ELF/Driver.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,15 +1327,13 @@ static void readConfigs(Ctx &ctx, opt::InputArgList &args) {
13271327
OPT_no_lto_validate_all_vtables_have_type_infos, false);
13281328
ctx.arg.ltoo = args::getInteger(args, OPT_lto_O, 2);
13291329
if (ctx.arg.ltoo > 3)
1330-
ErrAlways(ctx) << "invalid optimization level for LTO: "
1331-
<< Twine(ctx.arg.ltoo);
1330+
ErrAlways(ctx) << "invalid optimization level for LTO: " << ctx.arg.ltoo;
13321331
unsigned ltoCgo =
13331332
args::getInteger(args, OPT_lto_CGO, args::getCGOptLevel(ctx.arg.ltoo));
13341333
if (auto level = CodeGenOpt::getLevel(ltoCgo))
13351334
ctx.arg.ltoCgo = *level;
13361335
else
1337-
ErrAlways(ctx) << "invalid codegen optimization level for LTO: "
1338-
<< Twine(ltoCgo);
1336+
ErrAlways(ctx) << "invalid codegen optimization level for LTO: " << ltoCgo;
13391337
ctx.arg.ltoObjPath = args.getLastArgValue(OPT_lto_obj_path_eq);
13401338
ctx.arg.ltoPartitions = args::getInteger(args, OPT_lto_partitions, 1);
13411339
ctx.arg.ltoSampleProfile = args.getLastArgValue(OPT_lto_sample_profile);

lld/ELF/ICF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ template <class ELFT> void ICF<ELFT>::run() {
542542
});
543543
} while (repeat);
544544

545-
Log(ctx) << "ICF needed " << Twine(cnt) << " iterations";
545+
Log(ctx) << "ICF needed " << cnt << " iterations";
546546

547547
// Merge sections by the equivalence class.
548548
forEachClassRange(0, sections.size(), [&](size_t begin, size_t end) {

lld/ELF/InputFiles.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ static void updateARMVFPArgs(Ctx &ctx, const ARMAttributeParser &attributes,
133133
// Object compatible with all conventions.
134134
return;
135135
default:
136-
ErrAlways(ctx) << f
137-
<< ": unknown Tag_ABI_VFP_args value: " << Twine(vfpArgs);
136+
ErrAlways(ctx) << f << ": unknown Tag_ABI_VFP_args value: " << vfpArgs;
138137
return;
139138
}
140139
// Follow ld.bfd and error if there is a mix of calling conventions.
@@ -691,8 +690,7 @@ template <class ELFT> void ObjFile<ELFT>::parse(bool ignoreComdats) {
691690
// Otherwise, discard group members.
692691
for (uint32_t secIndex : entries.slice(1)) {
693692
if (secIndex >= size)
694-
Fatal(ctx) << this
695-
<< ": invalid section index in group: " << Twine(secIndex);
693+
Fatal(ctx) << this << ": invalid section index in group: " << secIndex;
696694
this->sections[secIndex] = &InputSection::discarded;
697695
}
698696
}
@@ -748,8 +746,8 @@ bool ObjFile<ELFT>::shouldMerge(const Elf_Shdr &sec, StringRef name) {
748746
return false;
749747
if (sec.sh_size % entSize)
750748
Fatal(ctx) << this << ":(" << name << "): SHF_MERGE section size ("
751-
<< Twine(sec.sh_size) << ") must be a multiple of sh_entsize ("
752-
<< Twine(entSize) << ")";
749+
<< uint64_t(sec.sh_size)
750+
<< ") must be a multiple of sh_entsize (" << entSize << ")";
753751

754752
if (sec.sh_flags & SHF_WRITE)
755753
Fatal(ctx) << this << ":(" << name
@@ -810,7 +808,7 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
810808
Warn(ctx) << this
811809
<< ": --icf=safe conservatively ignores "
812810
"SHT_LLVM_ADDRSIG [index "
813-
<< Twine(i)
811+
<< i
814812
<< "] with sh_link=0 "
815813
"(likely created using objcopy or ld -r)";
816814
}
@@ -939,7 +937,8 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
939937
if (sec.sh_link < size)
940938
linkSec = this->sections[sec.sh_link];
941939
if (!linkSec)
942-
Fatal(ctx) << this << ": invalid sh_link index: " << Twine(sec.sh_link);
940+
Fatal(ctx) << this
941+
<< ": invalid sh_link index: " << uint32_t(sec.sh_link);
943942

944943
// A SHF_LINK_ORDER section is discarded if its linked-to section is
945944
// discarded.
@@ -1167,7 +1166,7 @@ void ObjFile<ELFT>::initializeSymbols(const object::ELFFile<ELFT> &obj) {
11671166
if (LLVM_UNLIKELY(eSym.st_shndx == SHN_COMMON)) {
11681167
if (value == 0 || value >= UINT32_MAX)
11691168
Fatal(ctx) << this << ": common symbol '" << sym->getName()
1170-
<< "' has invalid alignment: " << Twine(value);
1169+
<< "' has invalid alignment: " << value;
11711170
hasCommonSyms = true;
11721171
sym->resolve(ctx, CommonSymbol{ctx, this, StringRef(), binding, stOther,
11731172
type, value, size});
@@ -1214,7 +1213,7 @@ void ObjFile<ELFT>::initSectionsAndLocalSyms(bool ignoreComdats) {
12141213
else if (secIdx >= SHN_LORESERVE)
12151214
secIdx = 0;
12161215
if (LLVM_UNLIKELY(secIdx >= sections.size()))
1217-
Fatal(ctx) << this << ": invalid section index: " << Twine(secIdx);
1216+
Fatal(ctx) << this << ": invalid section index: " << secIdx;
12181217
if (LLVM_UNLIKELY(eSym.getBinding() != STB_LOCAL))
12191218
ErrAlways(ctx) << this << ": non-local symbol (" << i
12201219
<< ") found at index < .symtab's sh_info (" << end << ")";
@@ -1274,7 +1273,7 @@ template <class ELFT> void ObjFile<ELFT>::postParse() {
12741273
else if (secIdx >= SHN_LORESERVE)
12751274
secIdx = 0;
12761275
if (LLVM_UNLIKELY(secIdx >= sections.size()))
1277-
Fatal(ctx) << this << ": invalid section index: " << Twine(secIdx);
1276+
Fatal(ctx) << this << ": invalid section index: " << secIdx;
12781277
InputSectionBase *sec = sections[secIdx];
12791278
if (sec == &InputSection::discarded) {
12801279
if (sym.traced) {
@@ -1577,8 +1576,8 @@ template <class ELFT> void SharedFile::parse() {
15771576
// as of binutils 2.34, GNU ld produces VER_NDX_LOCAL.
15781577
if (ver != VER_NDX_LOCAL && ver != VER_NDX_GLOBAL) {
15791578
if (idx >= verneeds.size()) {
1580-
ErrAlways(ctx) << "corrupt input file: version need index "
1581-
<< Twine(idx) << " for symbol " << name
1579+
ErrAlways(ctx) << "corrupt input file: version need index " << idx
1580+
<< " for symbol " << name
15821581
<< " is out of bounds\n>>> defined in " << this;
15831582
continue;
15841583
}
@@ -1602,8 +1601,8 @@ template <class ELFT> void SharedFile::parse() {
16021601
// VER_NDX_LOCAL. Workaround this bug.
16031602
if (ctx.arg.emachine == EM_MIPS && name == "_gp_disp")
16041603
continue;
1605-
ErrAlways(ctx) << "corrupt input file: version definition index "
1606-
<< Twine(idx) << " for symbol " << name
1604+
ErrAlways(ctx) << "corrupt input file: version definition index " << idx
1605+
<< " for symbol " << name
16071606
<< " is out of bounds\n>>> defined in " << this;
16081607
continue;
16091608
}

lld/ELF/InputSection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ void InputSectionBase::parseCompressedHeader(Ctx &ctx) {
274274
"not built with zstd support";
275275
} else {
276276
ErrAlways(ctx) << this << ": unsupported compression type ("
277-
<< Twine(hdr->ch_type) << ")";
277+
<< uint32_t(hdr->ch_type) << ")";
278278
return;
279279
}
280280

lld/ELF/LinkerScript.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,7 @@ static void checkMemoryRegion(Ctx &ctx, const MemoryRegion *region,
17841784
if (osecEnd > regionEnd) {
17851785
ErrAlways(ctx) << "section '" << osec->name << "' will not fit in region '"
17861786
<< region->name << "': overflowed by "
1787-
<< Twine(osecEnd - regionEnd) << " bytes";
1787+
<< (osecEnd - regionEnd) << " bytes";
17881788
}
17891789
}
17901790

lld/ELF/SyntheticSections.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,8 +2116,8 @@ template <class ELFT> bool RelrSection<ELFT>::updateAllocSize(Ctx &ctx) {
21162116
// Don't allow the section to shrink; otherwise the size of the section can
21172117
// oscillate infinitely. Trailing 1s do not decode to more relocations.
21182118
if (relrRelocs.size() < oldSize) {
2119-
Log(ctx) << ".relr.dyn needs " << Twine(oldSize - relrRelocs.size()) <<
2120-
" padding word(s)";
2119+
Log(ctx) << ".relr.dyn needs " << (oldSize - relrRelocs.size())
2120+
<< " padding word(s)";
21212121
relrRelocs.resize(oldSize, Elf_Relr(1));
21222122
}
21232123

@@ -2870,7 +2870,7 @@ void DebugNamesBaseSection::parseDebugNames(
28702870
nd.hdr = ni.getHeader();
28712871
if (nd.hdr.Format != DwarfFormat::DWARF32) {
28722872
Err(ctx) << namesSec.sec
2873-
<< Twine(": found DWARF64, which is currently unsupported");
2873+
<< ": found DWARF64, which is currently unsupported";
28742874
return;
28752875
}
28762876
if (nd.hdr.Version != 5) {
@@ -2880,8 +2880,7 @@ void DebugNamesBaseSection::parseDebugNames(
28802880
uint32_t dwarfSize = dwarf::getDwarfOffsetByteSize(DwarfFormat::DWARF32);
28812881
DWARFDebugNames::DWARFDebugNamesOffsets locs = ni.getOffsets();
28822882
if (locs.EntriesBase > namesExtractor.getData().size()) {
2883-
Err(ctx) << namesSec.sec
2884-
<< Twine(": entry pool start is beyond end of section");
2883+
Err(ctx) << namesSec.sec << ": entry pool start is beyond end of section";
28852884
return;
28862885
}
28872886

@@ -2962,7 +2961,7 @@ void DebugNamesBaseSection::computeHdrAndAbbrevTable(
29622961
// ForeignTypeUnitCount are left as 0.
29632962
if (nd.hdr.LocalTypeUnitCount || nd.hdr.ForeignTypeUnitCount)
29642963
Warn(ctx) << inputChunk.section.sec
2965-
<< Twine(": type units are not implemented");
2964+
<< ": type units are not implemented";
29662965
// If augmentation strings are not identical, use an empty string.
29672966
if (i == 0) {
29682967
hdr.AugmentationStringSize = nd.hdr.AugmentationStringSize;

lld/ELF/Target.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void elf::setTarget(Ctx &ctx) {
8484
case EM_X86_64:
8585
return setX86_64TargetInfo(ctx);
8686
default:
87-
Fatal(ctx) << "unsupported e_machine value: " << Twine(ctx.arg.emachine);
87+
Fatal(ctx) << "unsupported e_machine value: " << ctx.arg.emachine;
8888
}
8989
}
9090

lld/ELF/Target.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ inline void checkAlignment(Ctx &ctx, uint8_t *loc, uint64_t v, int n,
292292
if ((v & (n - 1)) != 0)
293293
Err(ctx) << getErrorLoc(ctx, loc) << "improper alignment for relocation "
294294
<< rel.type << ": 0x" << llvm::utohexstr(v)
295-
<< " is not aligned to " << Twine(n) << " bytes";
295+
<< " is not aligned to " << n << " bytes";
296296
}
297297

298298
// Endianness-aware read/write.

lld/ELF/Writer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,8 +1572,8 @@ template <class ELFT> void Writer<ELFT>::finalizeAddressDependentContent() {
15721572
if (osec->addr % osec->addralign != 0)
15731573
Warn(ctx) << "address (0x" << Twine::utohexstr(osec->addr)
15741574
<< ") of section " << osec->name
1575-
<< " is not a multiple of alignment ("
1576-
<< Twine(osec->addralign) << ")";
1575+
<< " is not a multiple of alignment (" << osec->addralign
1576+
<< ")";
15771577
}
15781578

15791579
// Sizes are no longer allowed to grow, so all allowable spills have been
@@ -2794,7 +2794,7 @@ template <class ELFT> void Writer<ELFT>::openFile() {
27942794
if (fileSize != size_t(fileSize) || maxSize < fileSize) {
27952795
std::string msg;
27962796
raw_string_ostream s(msg);
2797-
s << "output file too large: " << Twine(fileSize) << " bytes\n"
2797+
s << "output file too large: " << fileSize << " bytes\n"
27982798
<< "section sizes:\n";
27992799
for (OutputSection *os : ctx.outputSections)
28002800
s << os->name << ' ' << os->size << "\n";

0 commit comments

Comments
 (0)