[llvm] [OpenMPOpt] Fix incorrect end-of-kernel barrier removal (PR #65670)

Daniel Woodworth via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 27 09:32:02 PDT 2023


================
@@ -2621,6 +2621,17 @@ struct AAICVTrackerCallSiteReturned : AAICVTracker {
   }
 };
 
+/// Determines if \p BB exits the function unconditionally itself or reaches a
+/// block that does through only unique successors.
+static bool hasFunctionEndAsUniqueSuccessor(const BasicBlock *BB) {
+  if (succ_empty(BB))
+    return true;
+  const BasicBlock *const Successor = BB->getUniqueSuccessor();
+  if (!Successor)
+    return false;
+  return hasFunctionEndAsUniqueSuccessor(Successor);
----------------
dwoodwor-intel wrote:

Yes, this is tail recursion so it should be functionally equivalent

https://github.com/llvm/llvm-project/pull/65670


More information about the llvm-commits mailing list