[all-commits] [llvm/llvm-project] 03f668: [LICM][Coroutine] Don't sink stores from loops wit...

Xun Li via All-commits all-commits at lists.llvm.org
Wed Mar 3 15:22:31 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 03f668613c44714fe859e60c5775b6d8d46ac65d
      https://github.com/llvm/llvm-project/commit/03f668613c44714fe859e60c5775b6d8d46ac65d
  Author: Xun Li <lxfind at gmail.com>
  Date:   2021-03-03 (Wed, 03 Mar 2021)

  Changed paths:
    M llvm/docs/Coroutines.rst
    M llvm/lib/Transforms/Scalar/LICM.cpp
    M llvm/test/Transforms/Coroutines/ArgAddr.ll
    A llvm/test/Transforms/LICM/sink-with-coroutine.ll

  Log Message:
  -----------
  [LICM][Coroutine] Don't sink stores from loops with coro.suspend instructions

See pr46990(https://bugs.llvm.org/show_bug.cgi?id=46990). LICM should not sink store instructions to loop exit blocks which cross coro.suspend intrinsics. This breaks semantic of coro.suspend intrinsic which return to caller directly. Also this leads to use-after-free if the coroutine is freed before control returns to the caller in multithread environment.

This patch disable promotion by check whether loop contains coro.suspend intrinsics.
This is a resubmit of D86190.
Disabling LICM for loops with coroutine suspension is a better option not only for correctness purpose but also for performance purpose.
In most cases LICM sinks memory operations. In the case of coroutine, sinking memory operation out of the loop does not improve performance since coroutien needs to get data from the frame anyway. In fact LICM would hurt coroutine performance since it adds more entries to the frame.

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




More information about the All-commits mailing list