[PATCH] D143117: [BOLT][NFC] Simplify SW::checkStackPointerRestore

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 1 15:58:38 PST 2023


Amir created this revision.
Herald added a reviewer: rafauler.
Herald added subscribers: treapster, 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/D143117

Files:
  bolt/lib/Passes/ShrinkWrapping.cpp


Index: bolt/lib/Passes/ShrinkWrapping.cpp
===================================================================
--- bolt/lib/Passes/ShrinkWrapping.cpp
+++ bolt/lib/Passes/ShrinkWrapping.cpp
@@ -265,17 +265,11 @@
   // value may need to be updated depending on our stack layout changes
   const MCInstrDesc &InstInfo = BC.MII->get(Point.getOpcode());
   unsigned NumDefs = InstInfo.getNumDefs();
-  bool UsesFP = false;
-  for (unsigned I = NumDefs, E = MCPlus::getNumPrimeOperands(Point); I < E;
-       ++I) {
-    MCOperand &Operand = Point.getOperand(I);
-    if (!Operand.isReg())
-      continue;
-    if (Operand.getReg() == BC.MIB->getFramePointer()) {
-      UsesFP = true;
-      break;
-    }
-  }
+  bool UsesFP = llvm::any_of(
+      llvm::drop_begin(MCPlus::primeOperands(Point), NumDefs),
+      [&](MCOperand &Op) {
+        return Op.isReg() && Op.getReg() == BC.MIB->getFramePointer();
+      });
   if (!UsesFP)
     return;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143117.494098.patch
Type: text/x-patch
Size: 943 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230201/5c8d5de7/attachment.bin>


More information about the llvm-commits mailing list