[PATCH] D96441: [Coroutines] Don't use lifetime marker to decide whether an alloca should be put on the frame

Xun Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 10 11:05:32 PST 2021


lxfind created this revision.
Herald added subscribers: hoy, modimo, wenlei, hiraditya.
lxfind requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

In the current logic, we look at the lifetime.start marker of each alloca, and check all uses of the alloca, to see if any pair of the lifetime marker and an use of alloca crosses suspension point.
This approach is unfortunately incorrect. An use of alloca does not need to be a direct use, but can be an indirect use through alias.
Only checking direct uses can miss cases where indirect uses are crossing suspension point.
This can be demonstrated in the newly added test case.
In the test case, both x and y are only directly used prior to suspend, but they are captured into an alias, merged through a PHINode (so they coudln't be materialized), and used after CoroSuspend.
If we only check whether the lifetime starts corss suspension points with direct uses, we will put the allocas to the stack, and then capture their addresses in the frame.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96441

Files:
  llvm/lib/Transforms/Coroutines/CoroFrame.cpp
  llvm/test/Transforms/Coroutines/coro-alloca-07.ll
  llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
  llvm/test/Transforms/Coroutines/coro-split-sink-lifetime-03.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96441.322761.patch
Type: text/x-patch
Size: 9234 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210210/c9b5ba11/attachment.bin>


More information about the llvm-commits mailing list