Skip to content

Commit 87c7f4a

Browse files
committed
[MC] Remove unnecessary reversal of relocations. NFC
Commit f44db24 (2015) enabled this simplication.
1 parent d7ce6b4 commit 87c7f4a

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

llvm/lib/MC/ELFObjectWriter.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -939,18 +939,11 @@ void ELFWriter::writeRelocations(const MCAssembler &Asm,
939939
const MCSectionELF &Sec) {
940940
std::vector<ELFRelocationEntry> &Relocs = OWriter.Relocations[&Sec];
941941

942-
// We record relocations by pushing to the end of a vector. Reverse the vector
943-
// to get the relocations in the order they were created.
944-
// In most cases that is not important, but it can be for special sections
945-
// (.eh_frame) or specific relocations (TLS optimizations on SystemZ).
946-
std::reverse(Relocs.begin(), Relocs.end());
947-
948942
// Sort the relocation entries. MIPS needs this.
949943
OWriter.TargetObjectWriter->sortRelocs(Asm, Relocs);
950944

951945
const bool Rela = usesRela(Sec);
952-
for (unsigned i = 0, e = Relocs.size(); i != e; ++i) {
953-
const ELFRelocationEntry &Entry = Relocs[e - i - 1];
946+
for (const ELFRelocationEntry &Entry : Relocs) {
954947
unsigned Index = Entry.Symbol ? Entry.Symbol->getIndex() : 0;
955948

956949
if (is64Bit()) {

llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,9 @@ void MipsELFObjectWriter::sortRelocs(const MCAssembler &Asm,
498498

499499
assert(Relocs.size() == Sorted.size() && "Some relocs were not consumed");
500500

501-
// Overwrite the original vector with the sorted elements. The caller expects
502-
// them in reverse order.
501+
// Overwrite the original vector with the sorted elements.
503502
unsigned CopyTo = 0;
504-
for (const auto &R : reverse(Sorted))
503+
for (const auto &R : Sorted)
505504
Relocs[CopyTo++] = R.R;
506505
}
507506

0 commit comments

Comments
 (0)