[llvm] [LLVM][Coroutines] Introduce TBAA metadata for coro frame object (PR #176543)
Chuanqi Xu via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 21 23:24:51 PST 2026
ChuanqiXu9 wrote:
> (yes, I know SCEV might optimize out whatever I'm writing here, before the coros pass even, this example is just to illustrate)
>
> ```
> Generator<int> test(int n, int x, int *p) {
> co_yield 0
> for (int i = 0; i != n; ++i) {
> // CoroSplit reloads `p` and `x` inside the loop
> // If we had C++ TBAA typing for `frame`, the load/store into `frame->p` and reload of `x` (load `&frame->x`)
> // are MayAlias, since they are both accessing type int.
> // but of course, the address of frame->x is never taken anywhere and p is necessarily non-aliasing with it.
> *p += x;
> }
> }
> ```
>
> Regarding the TBAA roots, yes, I am just making it always use the C++ one.
What if the address of x are taken somewhere and how this PR handle that? e.g.,
```C++
void take(int &);
void take(int *&);
Generator<int> test(int n, int x, int *p) {
co_yield 0
take(x);
take(p);
for (int i = 0; i != n; ++i) {
// CoroSplit reloads `p` and `x` inside the loop
// If we had C++ TBAA typing for `frame`, the load/store into `frame->p` and reload of `x` (load `&frame->x`)
// are MayAlias, since they are both accessing type int.
// but of course, the address of frame->x is never taken anywhere and p is necessarily non-aliasing with it.
*p += x;
}
}
```
https://github.com/llvm/llvm-project/pull/176543
More information about the llvm-commits
mailing list