[llvm] [ObjCARC] Improve empty autorelease pool elimination in OptimizeAutoreleasePools (PR #200310)

Akira Hatanaka via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 2 18:56:12 PDT 2026


ahatanak wrote:

This doesn't look like an NFC change. It changes what gets eliminated, so it needs a test case demonstrating the behavioral difference.

Previously, on an AutoreleasepoolPop whose argument doesn't match the innermost push, the code popped the top of `PoolStack` before the mismatch check and then bailed. That left the outer entries on the stack, so a later pop could still match an outer push and eliminate that pair. Now a mismatched pop clears the whole stack, so nothing after it gets eliminated.

Consider a single block with the sequence `push0`, `push1`, `pop(X)`, `pop0`, where `pop(X)` is a pop that doesn't match the top push (`push1`), and `pop0` matches `push0`. Before this change, the `push0`/`pop0` pair was eliminated. After it, it isn't. Could you add a test along those lines that captures the new behavior?

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


More information about the llvm-commits mailing list