Skip to content

Commit 89b1468

Browse files
committed
[ELF] Move ppc64noTocRelax to Ctx. NFC
Ctx was introduced in March 2022 as a more suitable place for such singletons.
1 parent 947b9f5 commit 89b1468

File tree

7 files changed

+8
-11
lines changed

7 files changed

+8
-11
lines changed

lld/ELF/Arch/PPC64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1593,7 +1593,7 @@ void PPC64::relocateAlloc(InputSectionBase &sec, uint8_t *buf) const {
15931593
// entry, there may be R_PPC64_TOC16_HA not paired with
15941594
// R_PPC64_TOC16_LO_DS. Don't relax. This loses some relaxation
15951595
// opportunities but is safe.
1596-
if (ppc64noTocRelax.count({rel.sym, rel.addend}) ||
1596+
if (ctx.ppc64noTocRelax.count({rel.sym, rel.addend}) ||
15971597
!tryRelaxPPC64TocIndirection(rel, loc))
15981598
relocate(loc, rel, val);
15991599
break;

lld/ELF/Config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,11 @@ struct Ctx {
582582
unsigned scriptSymOrderCounter = 1;
583583
llvm::DenseMap<const Symbol *, unsigned> scriptSymOrder;
584584

585+
// The set of TOC entries (.toc + addend) for which we should not apply
586+
// toc-indirect to toc-relative relaxation. const Symbol * refers to the
587+
// STT_SECTION symbol associated to the .toc input section.
588+
llvm::DenseSet<std::pair<const Symbol *, uint64_t>> ppc64noTocRelax;
589+
585590
void reset();
586591

587592
llvm::raw_fd_ostream openAuxiliaryFile(llvm::StringRef, std::error_code &);

lld/ELF/Driver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ void Ctx::reset() {
123123
needsTlsLd.store(false, std::memory_order_relaxed);
124124
scriptSymOrderCounter = 1;
125125
scriptSymOrder.clear();
126+
ppc64noTocRelax.clear();
126127
ltoAllVtablesHaveTypeInfos = false;
127128
}
128129

lld/ELF/InputSection.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ using namespace llvm::sys;
3434
using namespace lld;
3535
using namespace lld::elf;
3636

37-
DenseSet<std::pair<const Symbol *, uint64_t>> elf::ppc64noTocRelax;
38-
3937
// Returns a string to construct an error message.
4038
std::string lld::toString(const InputSectionBase *sec) {
4139
return (toString(sec->file) + ":(" + sec->name + ")").str();

lld/ELF/InputSection.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,12 +498,6 @@ inline bool isDebugSection(const InputSectionBase &sec) {
498498
return (sec.flags & llvm::ELF::SHF_ALLOC) == 0 &&
499499
sec.name.starts_with(".debug");
500500
}
501-
502-
// The set of TOC entries (.toc + addend) for which we should not apply
503-
// toc-indirect to toc-relative relaxation. const Symbol * refers to the
504-
// STT_SECTION symbol associated to the .toc input section.
505-
extern llvm::DenseSet<std::pair<const Symbol *, uint64_t>> ppc64noTocRelax;
506-
507501
} // namespace elf
508502

509503
std::string toString(const elf::InputSectionBase *);

lld/ELF/Relocations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ void RelocationScanner::scanOne(typename Relocs<RelTy>::const_iterator &i) {
14951495
// InputSectionBase::relocateAlloc().
14961496
if (type == R_PPC64_TOC16_LO && sym.isSection() && isa<Defined>(sym) &&
14971497
cast<Defined>(sym).section->name == ".toc")
1498-
ppc64noTocRelax.insert({&sym, addend});
1498+
ctx.ppc64noTocRelax.insert({&sym, addend});
14991499

15001500
if ((type == R_PPC64_TLSGD && expr == R_TLSDESC_CALL) ||
15011501
(type == R_PPC64_TLSLD && expr == R_TLSLD_HINT)) {

lld/ELF/Writer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1800,7 +1800,6 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
18001800
// that we can correctly decide if a dynamic relocation is needed. This is
18011801
// called after processSymbolAssignments() because it needs to know whether
18021802
// a linker-script-defined symbol is absolute.
1803-
ppc64noTocRelax.clear();
18041803
scanRelocations<ELFT>();
18051804
reportUndefinedSymbols();
18061805
postScanRelocations();

0 commit comments

Comments
 (0)