D82314 has implemented a method for coroutine frame reducing in sinkLifetimeStartMarkers, which sink lifetime.start marker to multiple users. However, this may cause mismatch. Consider this :
coroutine A(){
a;
lifetime.start(a);
if (b)
{
... // do something
co_await
use(a);
}
use(a);
lifetime.end(a);
}Since both user of a do not dominate each other, we just sink lifetime.start for both of them. This may cause buildCoroutineFrame to keep a as local variable. More importantly, it introduces the pattern in resume function such like:
lifetime.start(a); use(a); lifetime.start(a); use(a); lifetime.end(a);
which cause wrong optimization in later passes.
This patch rewrite sinkLifetimeStartMarkers which only sink lifetime.start markers when all of its user are only used inside one of suspended region.
TestPlan: cppcoro, check-llvm, https://godbolt.org/z/zVx_eB
clang-tidy: warning: invalid case style for variable 'isUsedByLifetimeStart' [readability-identifier-naming]
not useful