[llvm] [coroutines][CoroSplit] Store allocas on the frame if there is no exp… …licit lifetime.end (PR #88806)
Chuanqi Xu via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 15 20:02:52 PDT 2024
https://github.com/ChuanqiXu9 commented:
Thanks for the analysis, it is pretty helpful.
>From the analysis, I feel there is deep problems in the current model since it shows the lifetime intrinsics is not so stable as we thought. e.g., if there are multiple llvm.lifetime.start and llvm.lifetime.end intrinsics but some passes only remove some of the `llvm.lifetime.end` intrinsics (not all), I fear it may still be problematic.
The root problem here is that, when we use lifetime info to decide if an alloca should live on the frame, we don't consider lifetime end at all. This is not correct. To fix this fundamentally, I think we need to introduce some data flow analysis here. The logic may be:
1. If there is any path from any llvm.lifetime.start to the llvm.coro.end with touching llvm.lifetime.end, we need to put the variable on the frame.
2. If there is any path from any llvm.lifetime.start to the llvm.lifetime.end touches llvm.coro.suspend, we need to put the variable on the frame.
3. Then it may be safe to put the variable on the stack.
I am not sure if there is existing logic for this. If not, probably we need to do it ourselves. We already did some of such local data flow analysis in coroutines.
https://github.com/llvm/llvm-project/pull/88806
More information about the llvm-commits
mailing list