================
@@ -706,16 +723,101 @@ void MachineSMEABI::insertStateChanges(EmitContext 
&Context,
 
 static DebugLoc getDebugLoc(MachineBasicBlock &MBB,
                             MachineBasicBlock::iterator MBBI) {
-  if (MBBI != MBB.end())
-    return MBBI->getDebugLoc();
-  return DebugLoc();
+  if (MBB.empty())
+    return DebugLoc();
+  return MBBI != MBB.end() ? MBBI->getDebugLoc() : MBB.back().getDebugLoc();
+}
+
+static bool findMarkedCall(const MachineBasicBlock &MBB,
+                           MachineBasicBlock::const_iterator MBBI,
+                           SmallVectorImpl<const MachineInstr *> &Calls,
+                           unsigned Marker, unsigned CallDestroyOpcode) {
+  auto IsMarker = [&](auto &MI) { return MI.getOpcode() == Marker; };
+  auto MarkerInst = std::find_if(MBBI, MBB.end(), IsMarker);
+  if (MarkerInst == MBB.end())
+    return false;
+  MachineBasicBlock::const_iterator I = MarkerInst;
+  while (++I != MBB.end()) {
+    if (I->isCall() || I->getOpcode() == CallDestroyOpcode)
+      break;
+  }
+  if (I != MBB.end() && I->isCall())
+    Calls.push_back(&*I);
+  // Note: This function always returns true if a "Marker" was found.
+  return true;
+}
+
+void MachineSMEABI::collectReachableMarkedCalls(
----------------
MacDue wrote:

There's a doc comment for `collectReachableMarkedCalls` on the `MachineSMEABI` 
class. I've added a doc comment for `findMarkedCall` :+1:  

https://github.com/llvm/llvm-project/pull/170277
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to