[llvm] [ObjCARC] Change autorelease to release when the pool state is not changed between the autorelease and the pool pop (PR #152353)

John McCall via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 22 08:48:40 PST 2026


================
@@ -121,6 +121,63 @@ static const Value *FindSingleUseIdentifiedObject(const Value *Arg) {
 /// \defgroup ARCOpt ARC Optimization.
 /// @{
 
+/// Check if there is an autoreleasePoolPop after the given autorelease
+/// instruction in the same basic block with no intervening calls that
+/// could affect the autorelease pool.
+static bool HasFollowingAutoreleasePoolPop(Instruction *AutoreleaseInst) {
+  assert(IsAutorelease(GetBasicARCInstKind(AutoreleaseInst)));
+  BasicBlock *BB = AutoreleaseInst->getParent();
+
+  // Look forward from the autorelease instruction
+  for (BasicBlock::iterator I = std::next(AutoreleaseInst->getIterator()),
+                            E = BB->end();
----------------
rjmccall wrote:

Is this going to be a compile-time performance problem? Seems quadratic.

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


More information about the llvm-commits mailing list