[llvm] bf5cd42 - [MIPS] Remove expensive LLVM_DEBUG relocation dump
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 18 11:24:48 PDT 2024
Author: Fangrui Song
Date: 2024-08-18T11:24:44-07:00
New Revision: bf5cd4220d20d0ee5533d55f463612fbe2980071
URL: https://github.com/llvm/llvm-project/commit/bf5cd4220d20d0ee5533d55f463612fbe2980071
DIFF: https://github.com/llvm/llvm-project/commit/bf5cd4220d20d0ee5533d55f463612fbe2980071.diff
LOG: [MIPS] Remove expensive LLVM_DEBUG relocation dump
The input is usually ordered by offset, so inspecting the output is
sufficient. The super expensive relocation dump is not conventional.
Added:
Modified:
llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
index 4d6a00c14a3575..1f047020d96c80 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
@@ -47,13 +47,6 @@ struct MipsRelocationEntry {
}
};
-#ifndef NDEBUG
-raw_ostream &operator<<(raw_ostream &OS, const MipsRelocationEntry &RHS) {
- RHS.print(OS);
- return OS;
-}
-#endif
-
class MipsELFObjectWriter : public MCELFObjectTargetWriter {
public:
MipsELFObjectWriter(uint8_t OSABI, bool HasRelocationAddend, bool Is64);
@@ -115,17 +108,11 @@ static InputIt find_best(InputIt First, InputIt Last, UnaryPredicate Predicate,
for (InputIt I = First; I != Last; ++I) {
unsigned Matched = Predicate(*I);
if (Matched != FindBest_NoMatch) {
- LLVM_DEBUG(dbgs() << std::distance(First, I) << " is a match (";
- I->print(dbgs()); dbgs() << ")\n");
- if (Best == Last || BetterThan(*I, *Best)) {
- LLVM_DEBUG(dbgs() << ".. and it beats the last one\n");
+ if (Best == Last || BetterThan(*I, *Best))
Best = I;
- }
}
- if (Matched == FindBest_PerfectMatch) {
- LLVM_DEBUG(dbgs() << ".. and it is unbeatable\n");
+ if (Matched == FindBest_PerfectMatch)
break;
- }
}
return Best;
@@ -201,15 +188,6 @@ static bool compareMatchingRelocs(const MipsRelocationEntry &Candidate,
return PreviousBest.Matched && !Candidate.Matched;
}
-#ifndef NDEBUG
-/// Print all the relocations.
-template <class Container>
-static void dumpRelocs(const char *Prefix, const Container &Relocs) {
- for (const auto &R : Relocs)
- dbgs() << Prefix << R << "\n";
-}
-#endif
-
MipsELFObjectWriter::MipsELFObjectWriter(uint8_t OSABI,
bool HasRelocationAddend, bool Is64)
: MCELFObjectTargetWriter(Is64, OSABI, ELF::EM_MIPS, HasRelocationAddend) {}
@@ -448,8 +426,6 @@ void MipsELFObjectWriter::sortRelocs(const MCAssembler &Asm,
std::list<MipsRelocationEntry> Sorted;
std::list<ELFRelocationEntry> Remainder;
- LLVM_DEBUG(dumpRelocs("R: ", Relocs));
-
// Separate the movable relocations (AHL relocations using the high bits) from
// the immobile relocations (everything else). This does not preserve high/low
// matches that already existed in the input.
@@ -459,8 +435,6 @@ void MipsELFObjectWriter::sortRelocs(const MCAssembler &Asm,
});
for (auto &R : Remainder) {
- LLVM_DEBUG(dbgs() << "Matching: " << R << "\n");
-
unsigned MatchingType = getMatchingLoType(R);
assert(MatchingType != ELF::R_MIPS_NONE &&
"Wrong list for reloc that doesn't need a match");
@@ -494,8 +468,6 @@ void MipsELFObjectWriter::sortRelocs(const MCAssembler &Asm,
Sorted.insert(InsertionPoint, R)->Matched = true;
}
- LLVM_DEBUG(dumpRelocs("S: ", Sorted));
-
assert(Relocs.size() == Sorted.size() && "Some relocs were not consumed");
// Overwrite the original vector with the sorted elements.
More information about the llvm-commits
mailing list