[PATCH] D100739: [Coroutines] Handle overaligned frame allocation (2)

Yuanfang Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 18 22:39:40 PDT 2021


ychen created this revision.
ychen added reviewers: rjmccall, lxfind, ChuanqiXu.
Herald added a subscriber: hiraditya.
ychen requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert.
Herald added projects: clang, LLVM.

This is an alternative to D97915 <https://reviews.llvm.org/D97915> which missed proper deallocation of the
over-allocated frame. This patch handles both allocations and deallocations.

Contrary to D97915 <https://reviews.llvm.org/D97915>, this patch implements the over-allocation in the backend instead of the frontend since

- The alloca of the raw frame pointer (suppose we insert it in the frontend) would be included in the non-overaligned frame if we don't teach CoroFrame how to elide it.
- Only insert extra code when it is known that the frame is overaligned.
- Simpler implementation.
- Clients could turn it on/off by setting the newly introduced argument of `llvm.coro.size(i1 alloc)`.

`llvm.coro.size` gains it first argument `i1 alloc` to indicate users of the intrinsic are alloc/dealloc functions. It also indicates to LLVM that it should handle overaligned frames. One con of doing this is that many tests need fixup (if the general direction is agreed upon, I'll do that later).

It gets a little tricky finding the deallocation function. It is assumed that all CallInst users of `llvm.coro.free` are potentially deallocation functions. I think this should be the implicit assumption in practice although the documentation `Coroutines.rst` does not mention that. Happy to better idea in this regard.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D100739

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  llvm/docs/Coroutines.rst
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Transforms/Coroutines/CoroFrame.cpp
  llvm/lib/Transforms/Coroutines/CoroInstr.h
  llvm/lib/Transforms/Coroutines/CoroInternal.h
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/lib/Transforms/Coroutines/Coroutines.cpp
  llvm/test/Transforms/Coroutines/ArgAddr.ll
  llvm/test/Transforms/Coroutines/coro-alloc-with-param-O0.ll
  llvm/test/Transforms/Coroutines/coro-alloca-01.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100739.338428.patch
Type: text/x-patch
Size: 19484 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210419/b601af57/attachment-0001.bin>


More information about the cfe-commits mailing list