[PATCH] D131811: [BOLT][NFC] Simplify addRelocation
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 12 14:46:30 PDT 2022
Amir created this revision.
Herald added a reviewer: rafauler.
Herald added a subscriber: ayermolo.
Herald added a reviewer: maksfb.
Herald added a project: All.
Amir requested review of this revision.
Herald added subscribers: llvm-commits, yota9.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D131811
Files:
bolt/include/bolt/Core/BinarySection.h
bolt/lib/Core/BinarySection.cpp
Index: bolt/lib/Core/BinarySection.cpp
===================================================================
--- bolt/lib/Core/BinarySection.cpp
+++ bolt/lib/Core/BinarySection.cpp
@@ -176,6 +176,22 @@
void BinarySection::clearRelocations() { clearList(Relocations); }
+void BinarySection::addRelocation(uint64_t Offset, MCSymbol *Symbol,
+ uint64_t Type, uint64_t Addend,
+ uint64_t Value, bool Pending) {
+ assert(Offset < getSize() && "offset not within section bounds");
+ LLVM_DEBUG({
+ dbgs() << "BOLT-DEBUG: addRelocation in " << getName() << ", @"
+ << Twine::utohexstr(Offset) << " against " << Symbol->getName()
+ << '\n';
+ });
+ Relocation R{Offset, Symbol, Type, Addend, Value};
+ if (Pending)
+ PendingRelocations.emplace_back(R);
+ else
+ Relocations.emplace(R);
+}
+
void BinarySection::print(raw_ostream &OS) const {
OS << getName() << ", "
<< "0x" << Twine::utohexstr(getAddress()) << ", " << getSize() << " (0x"
Index: bolt/include/bolt/Core/BinarySection.h
===================================================================
--- bolt/include/bolt/Core/BinarySection.h
+++ bolt/include/bolt/Core/BinarySection.h
@@ -317,15 +317,7 @@
/// Add a new relocation at the given /p Offset.
void addRelocation(uint64_t Offset, MCSymbol *Symbol, uint64_t Type,
uint64_t Addend, uint64_t Value = 0,
- bool Pending = false) {
- assert(Offset < getSize() && "offset not within section bounds");
- if (!Pending) {
- Relocations.emplace(Relocation{Offset, Symbol, Type, Addend, Value});
- } else {
- PendingRelocations.emplace_back(
- Relocation{Offset, Symbol, Type, Addend, Value});
- }
- }
+ bool Pending = false);
/// Add a dynamic relocation at the given /p Offset.
void addDynamicRelocation(uint64_t Offset, MCSymbol *Symbol, uint64_t Type,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131811.452308.patch
Type: text/x-patch
Size: 1973 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220812/f2a136a5/attachment.bin>
More information about the llvm-commits
mailing list