[llvm] [PromoteMemToReg] Insert store undef when removing lifetime markers (PR #191909)
Akshay Deodhar via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 4 17:46:00 PDT 2026
akshayrdeodhar wrote:
> > It stops live-in propagation at the lifetime.start block and adds that block to IDF’s defining set, preventing false loop-carried PHIs without introducing a new undef store.
>
> It would probably work too. I originally tried to carry around those boundaries (for both `start` and `end`), but it was too error prone in the sense that if the algorithm changed we had to be careful (and I was working on a slightly out-of-date version of LLVM). The advantage of `store undef` is that it is robust. I also assumed it would have no lasting effect because they only get introduced after we decided to promote the object, therefore they are guaranteed to be deleted. But seems there are traces of it remaining in the debug value (which I think is reasonable, but still).
>
> I think if I found a motivating example for C/C++ on x86 there would be more eyeballs on this. I think it is doable (probably need to declare a small array/struct inside a loop that benefit from being promoted without recurrent phi, typically due to register pressure) but I haven't had time to work on it.
In case it still helps, here is a C++ example where we have an unnecessary phi: https://godbolt.org/z/3TbdsKoc1. I'm seeing a similar issue internally, and would be happy to see this merged.
I am not versed in DebugInfo, however, and am unable to help there.
https://github.com/llvm/llvm-project/pull/191909
More information about the llvm-commits
mailing list