[clang] [Coroutines] Mark parameter allocas with coro.outside.frame metadata (PR #127653)

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 19 00:27:29 PST 2025


zmodem wrote:

> Adding metadata to an instruction should never be required for correctness

I figured the existing use and the fact that it only needs to survive until CoroSplit made it good enough. But you're right, we should do better.

I do think we need an explicit way to tell CoroSplit whether an alloca should go in the frame or not. I was thinking of adding an intrinsic when I found this metadata.

How about turning `coro.outside.frame` into an intrinsic instead?

> I don't feel the previous approach is too problematic.

I was concerned that it relied on semantics which aren't really defined. There is nothing in the langref which says that the coro frame cannot be accessed after coro.end. As far as I can tell, doing so might be fine as long as the frame hasn't been deallocated, which we can't infer statically.

In fact, my change broke a test which seems to be doing exactly that. Just because it's old doesn't mean it was wrong. So the patch didn't feel solid.

On the other hand, the frontend knows exactly what's going on with these parameter allocas: they should be outside the frame, so having a way to communicate that seems like a solid fix.

https://github.com/llvm/llvm-project/pull/127653


More information about the cfe-commits mailing list