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