[PATCH] D131811: [BOLT][NFC] Simplify addRelocation

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 18 17:43:04 PDT 2022


Amir updated this revision to Diff 453847.
Amir added a comment.

Reverting emplace/move ctor behavior


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131811/new/

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,21 @@
 
 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() << formatv(
+                 "BOLT-DEBUG: addRelocation in {0}, @{1:x} against {2}\n",
+                 getName(), Offset, Symbol->getName()));
+  if (Pending) {
+    PendingRelocations.emplace_back(
+        Relocation{Offset, Symbol, Type, Addend, Value});
+  } else {
+    Relocations.emplace(Relocation{Offset, Symbol, Type, Addend, Value});
+  }
+}
+
 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
@@ -326,16 +326,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});
-    }
-  }
+                     uint64_t Addend, uint64_t Value = 0, 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.453847.patch
Type: text/x-patch
Size: 2049 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220819/7050e9eb/attachment.bin>


More information about the llvm-commits mailing list