HomePhabricator

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

Authored by lxfind on Mar 3 2021, 3:21 PM.

Description

[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

Details

Committed
lxfindMar 3 2021, 3:21 PM
Differential Revision
D96928: [LICM][Coroutine] Don't sink stores from loops with coro.suspend instructions
Parents
rG30ad7b5dadcd: [test] Fix profiling.ll
Branches
Unknown
Tags
Unknown