Skip to content

Commit

Permalink
COFF: Make SectionChunk::Relocs field an ArrayRef. NFCI.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D45714

llvm-svn: 330172
  • Loading branch information
pcc committed Apr 17, 2018
1 parent 10664fc commit 2f6d006
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
3 changes: 1 addition & 2 deletions lld/COFF/Chunks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ namespace coff {

SectionChunk::SectionChunk(ObjFile *F, const coff_section *H)
: Chunk(SectionKind), Repl(this), Header(H), File(F),
Relocs(File->getCOFFObj()->getRelocations(Header)),
NumRelocs(std::distance(Relocs.begin(), Relocs.end())) {
Relocs(File->getCOFFObj()->getRelocations(Header)) {
// Initialize SectionName.
File->getCOFFObj()->getSectionName(Header, SectionName);

Expand Down
3 changes: 1 addition & 2 deletions lld/COFF/Chunks.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ class SectionChunk final : public Chunk {
private:
StringRef SectionName;
std::vector<SectionChunk *> AssocChildren;
llvm::iterator_range<const coff_relocation *> Relocs;
size_t NumRelocs;
ArrayRef<coff_relocation> Relocs;

// Used by the garbage collector.
bool Live;
Expand Down
4 changes: 2 additions & 2 deletions lld/COFF/ICF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class ICF {

// Returns a hash value for S.
uint32_t ICF::getHash(SectionChunk *C) {
return hash_combine(C->getPermissions(), C->SectionName, C->NumRelocs,
return hash_combine(C->getPermissions(), C->SectionName, C->Relocs.size(),
C->Alignment, uint32_t(C->Header->SizeOfRawData),
C->Checksum, C->getContents());
}
Expand Down Expand Up @@ -123,7 +123,7 @@ void ICF::segregate(size_t Begin, size_t End, bool Constant) {
// Compare "non-moving" part of two sections, namely everything
// except relocation targets.
bool ICF::equalsConstant(const SectionChunk *A, const SectionChunk *B) {
if (A->NumRelocs != B->NumRelocs)
if (A->Relocs.size() != B->Relocs.size())
return false;

// Compare relocations.
Expand Down
3 changes: 1 addition & 2 deletions llvm/include/llvm/Object/COFF.h
Original file line number Diff line number Diff line change
Expand Up @@ -1012,8 +1012,7 @@ class COFFObjectFile : public ObjectFile {
llvm_unreachable("null symbol table pointer!");
}

iterator_range<const coff_relocation *>
getRelocations(const coff_section *Sec) const;
ArrayRef<coff_relocation> getRelocations(const coff_section *Sec) const;

std::error_code getSectionName(const coff_section *Sec, StringRef &Res) const;
uint64_t getSectionSize(const coff_section *Sec) const;
Expand Down
9 changes: 3 additions & 6 deletions llvm/lib/Object/COFFObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,13 +1147,10 @@ COFFObjectFile::getCOFFRelocation(const RelocationRef &Reloc) const {
return toRel(Reloc.getRawDataRefImpl());
}

iterator_range<const coff_relocation *>
ArrayRef<coff_relocation>
COFFObjectFile::getRelocations(const coff_section *Sec) const {
const coff_relocation *I = getFirstReloc(Sec, Data, base());
const coff_relocation *E = I;
if (I)
E += getNumberOfRelocations(Sec, Data, base());
return make_range(I, E);
return {getFirstReloc(Sec, Data, base()),
getNumberOfRelocations(Sec, Data, base())};
}

#define LLVM_COFF_SWITCH_RELOC_TYPE_NAME(reloc_type) \
Expand Down

0 comments on commit 2f6d006

Please sign in to comment.