[PATCH] D132089: [BOLT][NFC] Simplify handleRelocation

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 18 14:19:44 PST 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG43f382a9f4a8: [BOLT][NFC] Simplify handleRelocation (authored by Amir).
Herald added a subscriber: treapster.

Changed prior to commit:
  https://reviews.llvm.org/D132089?vs=453519&id=490292#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132089

Files:
  bolt/lib/Rewrite/RewriteInstance.cpp


Index: bolt/lib/Rewrite/RewriteInstance.cpp
===================================================================
--- bolt/lib/Rewrite/RewriteInstance.cpp
+++ bolt/lib/Rewrite/RewriteInstance.cpp
@@ -2537,12 +2537,12 @@
             BC->getBinaryFunctionAtAddress(Address + 1)) {
       // Do an extra check that the function was referenced previously.
       // It's a linear search, but it should rarely happen.
-      bool Found =
-          llvm::any_of(llvm::make_second_range(ContainingBF->Relocations),
-                       [&](const Relocation &Rel) {
-                         return Rel.Symbol == RogueBF->getSymbol() &&
-                                !Relocation::isPCRelative(Rel.Type);
-                       });
+      auto CheckReloc = [&](const Relocation &Rel) {
+        return Rel.Symbol == RogueBF->getSymbol() &&
+               !Relocation::isPCRelative(Rel.Type);
+      };
+      bool Found = llvm::any_of(
+          llvm::make_second_range(ContainingBF->Relocations), CheckReloc);
 
       if (Found) {
         errs() << "BOLT-WARNING: detected possible compiler de-virtualization "
@@ -2675,15 +2675,13 @@
 
   auto checkMaxDataRelocations = [&]() {
     ++NumDataRelocations;
-    if (opts::MaxDataRelocations &&
-        NumDataRelocations + 1 == opts::MaxDataRelocations) {
-      LLVM_DEBUG({
-        dbgs() << "BOLT-DEBUG: processing ending on data relocation "
-               << NumDataRelocations << ": ";
-      });
+    LLVM_DEBUG(if (opts::MaxDataRelocations &&
+                   NumDataRelocations + 1 == opts::MaxDataRelocations) {
+      dbgs() << "BOLT-DEBUG: processing ending on data relocation "
+             << NumDataRelocations << ": ";
       printRelocationInfo(Rel, ReferencedSymbol->getName(), SymbolAddress,
                           Addend, ExtractedValue);
-    }
+    });
 
     return (!opts::MaxDataRelocations ||
             NumDataRelocations < opts::MaxDataRelocations);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132089.490292.patch
Type: text/x-patch
Size: 1943 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230118/09ee077e/attachment.bin>


More information about the llvm-commits mailing list