[Mlir-commits] [llvm] [mlir] [polly] [IR] Only allow lifetime.start/end on allocas (PR #149310)
Nikita Popov
llvmlistbot at llvm.org
Sat Jul 26 12:09:27 PDT 2025
nikic wrote:
> One approach is to introduce an intrinsic `void llvm,write.undef.i64(ptr, i64)` which is just a write of N bytes of undef to the memory in question. Transforms would model it like memset, except it doesn't actually lower to any code. This would allow dead store elimination, and not much else. Not very powerful, but easy to implement, and maybe useful in some cases. I think this is basically equivalent to what lifetime.start and lifetime.end did for non-alloca memory.
This is the design I had in mind. A benefit of divorcing this from any lifetime related concepts is that we could use this to solve the loop DSE problem (have LIR insert this intrinsic before loops, allowing DSE to work as usual).
A minor variant on this would be to not actually use a separate intrinsic for this, but just use `memset(undef)`. Currently we drop this in the middle-end, but we could preserve it and instead drop it during intrinsic lowering in the backend (we could make that a guarantee). That might be the most elegant solution, in that I'd expect it to mostly work out of the box...
https://github.com/llvm/llvm-project/pull/149310
More information about the Mlir-commits
mailing list