[llvm] [ObjCARC] Optimize MayAutorelease by skipping over pools (PR #188583)

via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 3 14:41:39 PDT 2026


SiliconA-Z wrote:

> The test looks good.
> 
> The implementation works, but I think there's room for improvement. How about using a stack of booleans? Push false onto the stack every time you see a pool push and pop from the stack every time you see a pool pop (unless it's already empty). When you encounter an instruction that may autorelease, return true immediately if the stack is empty (we're outside any pool), otherwise set the top of the stack to true. After the loop, if any entry on the stack has its flag set (an unmatched push contained an autorelease that may escape), return true, otherwise return false.
> 
> This avoids the quadratic worst case from the nested loop and keeps the iteration structure simple (single pass and no inner loop).

Done!

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


More information about the llvm-commits mailing list