[PATCH] D37093: [coroutines] Promote cleanup.dest.slot-like allocas to registers to avoid storing them in the coroutine frame
Gor Nishanov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 23 22:52:13 PDT 2017
GorNishanov created this revision.
Herald added subscribers: EricWF, qcolombet.
Allocas that follow the pattern of cleanup.dest.slot, namely, they are
integer allocas that don't escape and only store constants. We don't want
them to be saved into the coroutine frame (as some of the cleanup code may
access them after coroutine frame destroyed).
For example in this coroutine %slot will be promoted to register even in -O0
define i8* @happy.case() "coroutine.presplit"="1" {
entry:
%slot = alloca i32
%id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
%size = call i32 @llvm.coro.size.i32()
%alloc = call i8* @malloc(i32 %size)
%hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
store i32 1, i32* %slot
%tok = call i8 @llvm.coro.suspend(token none, i1 false)
switch i8 %tok, label %suspend [i8 0, label %resume
i8 1, label %cleanup]
resume:
store i32 2, i32* %slot
br label %cleanup
cleanup:
%mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
call void @free(i8* %mem)
%x = load i32, i32* %slot
call void @print.i32(i32 %x)
br label %suspend
suspend:
call i1 @llvm.coro.end(i8* %hdl, i1 0)
ret i8* %hdl
}
This fixes PR34289
https://reviews.llvm.org/D37093
Files:
lib/Transforms/Coroutines/CoroFrame.cpp
test/Transforms/Coroutines/coro-spill-promote.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37093.112504.patch
Type: text/x-patch
Size: 6577 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170824/e92c027f/attachment.bin>
More information about the llvm-commits
mailing list