[PATCH] D144758: [BOLT][NFC] Simplify BinaryFunction::setTrapOnEntry

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 27 15:41:56 PST 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd77f96a9e0c8: [BOLT][NFC] Simplify BinaryFunction::setTrapOnEntry (authored by Amir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144758

Files:
  bolt/include/bolt/Core/BinaryFunction.h
  bolt/lib/Core/BinaryFunction.cpp


Index: bolt/lib/Core/BinaryFunction.cpp
===================================================================
--- bolt/lib/Core/BinaryFunction.cpp
+++ bolt/lib/Core/BinaryFunction.cpp
@@ -2902,16 +2902,12 @@
 void BinaryFunction::setTrapOnEntry() {
   clearDisasmState();
 
-  auto addTrapAtOffset = [&](uint64_t Offset) {
+  forEachEntryPoint([&](uint64_t Offset, const MCSymbol *Label) -> bool {
     MCInst TrapInstr;
     BC.MIB->createTrap(TrapInstr);
     addInstruction(Offset, std::move(TrapInstr));
-  };
-
-  addTrapAtOffset(0);
-  for (const std::pair<const uint32_t, MCSymbol *> &KV : getLabels())
-    if (getSecondaryEntryPointSymbol(KV.second))
-      addTrapAtOffset(KV.first);
+    return true;
+  });
 
   TrapsOnEntry = true;
 }
Index: bolt/include/bolt/Core/BinaryFunction.h
===================================================================
--- bolt/include/bolt/Core/BinaryFunction.h
+++ bolt/include/bolt/Core/BinaryFunction.h
@@ -1466,8 +1466,6 @@
 
   ArrayRef<uint8_t> getLSDATypeIndexTable() const { return LSDATypeIndexTable; }
 
-  const LabelsMapType &getLabels() const { return Labels; }
-
   IslandInfo &getIslandInfo() {
     assert(Islands && "function expected to have constant islands");
     return *Islands;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144758.500949.patch
Type: text/x-patch
Size: 1245 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230227/28a8db29/attachment.bin>


More information about the llvm-commits mailing list