COFF: Make SectionChunk::Relocs field an ArrayRef. NFCI.

Differential Revision: https://reviews.llvm.org/D45714

llvm-svn: 330172
This commit is contained in:
Peter Collingbourne 2018-04-17 01:54:34 +00:00
parent 10664fc5d3
commit 2f6d00612d
5 changed files with 8 additions and 14 deletions

View File

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

View File

@ -216,8 +216,7 @@ public:
private: private:
StringRef SectionName; StringRef SectionName;
std::vector<SectionChunk *> AssocChildren; std::vector<SectionChunk *> AssocChildren;
llvm::iterator_range<const coff_relocation *> Relocs; ArrayRef<coff_relocation> Relocs;
size_t NumRelocs;
// Used by the garbage collector. // Used by the garbage collector.
bool Live; bool Live;

View File

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

View File

@ -1012,8 +1012,7 @@ public:
llvm_unreachable("null symbol table pointer!"); llvm_unreachable("null symbol table pointer!");
} }
iterator_range<const coff_relocation *> ArrayRef<coff_relocation> getRelocations(const coff_section *Sec) const;
getRelocations(const coff_section *Sec) const;
std::error_code getSectionName(const coff_section *Sec, StringRef &Res) const; std::error_code getSectionName(const coff_section *Sec, StringRef &Res) const;
uint64_t getSectionSize(const coff_section *Sec) const; uint64_t getSectionSize(const coff_section *Sec) const;

View File

@ -1147,13 +1147,10 @@ COFFObjectFile::getCOFFRelocation(const RelocationRef &Reloc) const {
return toRel(Reloc.getRawDataRefImpl()); return toRel(Reloc.getRawDataRefImpl());
} }
iterator_range<const coff_relocation *> ArrayRef<coff_relocation>
COFFObjectFile::getRelocations(const coff_section *Sec) const { COFFObjectFile::getRelocations(const coff_section *Sec) const {
const coff_relocation *I = getFirstReloc(Sec, Data, base()); return {getFirstReloc(Sec, Data, base()),
const coff_relocation *E = I; getNumberOfRelocations(Sec, Data, base())};
if (I)
E += getNumberOfRelocations(Sec, Data, base());
return make_range(I, E);
} }
#define LLVM_COFF_SWITCH_RELOC_TYPE_NAME(reloc_type) \ #define LLVM_COFF_SWITCH_RELOC_TYPE_NAME(reloc_type) \