[all-commits] [llvm/llvm-project] d0f4af: [Coroutines] Insert lifetime intrinsics even O0 is...

junparser via All-commits all-commits at lists.llvm.org
Mon Mar 23 22:42:14 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: d0f4af8f3088f72df7fea9983127cbeeebbef6a1
      https://github.com/llvm/llvm-project/commit/d0f4af8f3088f72df7fea9983127cbeeebbef6a1
  Author: Jun Ma <JunMa at linux.alibaba.com>
  Date:   2020-03-24 (Tue, 24 Mar 2020)

  Changed paths:
    M clang/lib/CodeGen/BackendUtil.cpp
    A clang/test/CodeGenCoroutines/coro-always-inline.cpp

  Log Message:
  -----------
  [Coroutines] Insert lifetime intrinsics even O0 is used

Differential Revision: https://reviews.llvm.org/D76119


  Commit: a44de12ab2193c14b6f0ff8cbea8f276cbf10159
      https://github.com/llvm/llvm-project/commit/a44de12ab2193c14b6f0ff8cbea8f276cbf10159
  Author: Jun Ma <JunMa at linux.alibaba.com>
  Date:   2020-03-24 (Tue, 24 Mar 2020)

  Changed paths:
    M llvm/lib/Transforms/Coroutines/CoroFrame.cpp
    M llvm/lib/Transforms/Coroutines/CoroSplit.cpp
    M llvm/test/Transforms/Coroutines/coro-split-02.ll

  Log Message:
  -----------
  [Coroutines] Also check lifetime intrinsic for local variable when build
coroutine frame

Currently we move all allocas into the frame when build coroutine frame in
CoroSplit pass. However, this can be relaxed.

Since CoroSplit pass run after Inline pass, we can use lifetime intrinsic to
do such analysis: If the scope of lifetime intrinsic is not across any suspend
point, rather than move the allocas to frame, we can just move them to entry bb
of corresponding function. This reduce the frame size.

More importantly, this also avoid data race in multithread environment.
Consider one inline function by coroutine: it starts a thread which access
local variables, while after inline the movement of allocs to frame also access
them. cause data race.

Differential Revision: https://reviews.llvm.org/D75664


Compare: https://github.com/llvm/llvm-project/compare/b7cd291c1542...a44de12ab219


More information about the All-commits mailing list