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

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 26 14:52:03 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);
----------------
jdoerfert wrote:

It is likely not to matter here but we usually avoid recursion and go with loops.
Also, const BB * const is a long way to spell auto.

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


More information about the llvm-commits mailing list