[llvm] [ControlHeightReduction] Drop lifetime annotations where necessary (PR #159686)

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 19 12:38:04 PDT 2025


boomanaiden154 wrote:

> I don't think this fix is quite right. For your example, CHR does something very undesirable, which is to split blocks in a way that ends up duplicating a previously static alloca, turning it into two dynamic allocas. We should really make sure that static allocas stay static. Additionally, I'm concerned that your approach here may end up partially removing lifetime markers. If we drop any markers, we always need to drop all of them.

I've updated CHR to hoist static allocas to the true entry block. In that case we also don't need to generate a phi node and we can preserve the lifetime annotations. I've added another test case for dynamic allocas where we do need to remove lifetime annotations and update `insertTrivialPHIs` to drop all lifetime annotations if we end up in a situation where we are trying to annotate the lifetime of a phi.

> The issue here looks very similar to the problem I fixed in https://github.com/llvm/llvm-project/commit/fc90685354ca36c935ebb0f315bb18592598a83b. I think you basically want to do the same. That is, for static allocas, make sure they are not part of the splitting. And for dynamic allocas, drop all lifetime markers if any have to be dropped.

Thanks for the example that was super helpful. And thank you for the clear explanation/your patience as I get a better grip on the middle end.

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


More information about the llvm-commits mailing list