mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
e158b9df69
Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=36578 and https://bugs.llvm.org/show_bug.cgi?id=36296. Supersedes: https://reviews.llvm.org/D55966 One of the fundamental transformation that CoroSplit pass performs before splitting the coroutine is to find which values need to survive between suspend and resume and provide a slot for them in the coroutine frame to spill and restore the value as needed. Coroutine frame becomes available once the storage for it was allocated and that point is marked in the pre-split coroutine with a llvm.coro.begin intrinsic. FE normally puts all of the user-authored code that would be accessing those values after llvm.coro.begin, however, sometimes instructions accessing those values would end up prior to coro.begin. For example, writing out a value of the parameter into the alloca done by the FE or instructions that are added by the optimization passes such as SROA when it rewrites allocas. Prior to this change, CoroSplit pass would try to move instructions that may end up accessing the values in the coroutine frame after CoroBegin. However it would run into problems (report_fatal_error) if some of the values would be used both in the allocation function (for example allocator is passed as a parameter to a coroutine) and in the use-authored body of the coroutine. To handle this case and to simplify the instruction moving logic, this change removes all of the instruction moving. Instead, we only change the uses of the spilled values that are dominated by coro.begin and leave other instructions intact. Before: ``` %var = alloca i32 %1 = getelementptr .. %var; ; will move this one after coro.begin %f = call i8* @llvm.coro.begin( ``` After: ``` %var = alloca i32 %1 = getelementptr .. %var; stays put %f = call i8* @llvm.coro.begin( ``` If we discover that there is a potential write into an alloca, prior to coro.begin we would copy its value from the alloca into the spill slot in the coroutine frame. Before: ``` %var = alloca i32 store .. %var ; will move this one after coro.begin %f = call i8* @llvm.coro.begin( ``` After: ``` %var = alloca i32 store .. %var ;stays put %f = call i8* @llvm.coro.begin( %tmp = load %var store %tmp, %spill.slot.for.var ``` Note: This change does not handle array allocas as that is something that C++ FE does not produce, but, it can be added in the future if need arises Reviewers: llvm-commits, modocache, ben-clayton, tks2103, rjmccall Reviewed By: modocache Subscribers: bartdesmet Differential Revision: https://reviews.llvm.org/D66230 llvm-svn: 368949 |
||
---|---|---|
.. | ||
ArgAddr.ll | ||
coro-alloc-with-param.ll | ||
coro-catchswitch.ll | ||
coro-cleanup.ll | ||
coro-debug.ll | ||
coro-early.ll | ||
coro-eh-aware-edge-split.ll | ||
coro-elide.ll | ||
coro-frame-arrayalloca.ll | ||
coro-frame-unreachable.ll | ||
coro-frame.ll | ||
coro-heap-elide.ll | ||
coro-materialize.ll | ||
coro-padding.ll | ||
coro-param-copy.ll | ||
coro-retcon-alloca.ll | ||
coro-retcon-once-value2.ll | ||
coro-retcon-once-value.ll | ||
coro-retcon-resume-values2.ll | ||
coro-retcon-resume-values.ll | ||
coro-retcon-value.ll | ||
coro-retcon.ll | ||
coro-spill-after-phi.ll | ||
coro-spill-corobegin.ll | ||
coro-split-00.ll | ||
coro-split-01.ll | ||
coro-split-02.ll | ||
coro-split-alloc.ll | ||
coro-split-dbg.ll | ||
coro-split-eh.ll | ||
coro-split-hidden.ll | ||
coro-split-musttail.ll | ||
coro-swifterror.ll | ||
ex0.ll | ||
ex1.ll | ||
ex2.ll | ||
ex3.ll | ||
ex4.ll | ||
ex5.ll | ||
no-suspend.ll | ||
phi-coro-end.ll | ||
restart-trigger.ll | ||
smoketest.ll |