promise is a header field but it is not guaranteed that it would be the third
field of the frame due to performOptimizedStructLayout..
Details
- Reviewers
lxfind - Commits
- rG5c7dcd7aead7: [Coroutine] Update promise object's final layout index
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/Coroutines/CoroFrame.cpp | ||
---|---|---|
746 | PromiseAlloca is added here as a header field, which means it should have a fixed index? |
llvm/lib/Transforms/Coroutines/CoroFrame.cpp | ||
---|---|---|
746 | I'm inclined to say it should be fixed offset which is not changed after performOptimizedStructLayout.
/// - Fields may be assigned a fixed offset in the layout. If there are /// gaps among the fixed-offset fields, the algorithm may attempt /// to allocate flexible-offset fields into those gaps. If that's /// undesirable, the caller should "block out" those gaps by e.g. /// just creating a single fixed-offset field that represents the /// entire "header". |
llvm/lib/Transforms/Coroutines/CoroFrame.cpp | ||
---|---|---|
746 | You are right. |
llvm/lib/Transforms/Coroutines/CoroFrame.cpp | ||
---|---|---|
746 | Yeah, that's an option too. TBH, I'm not quite sure about the importance or implication of PromiseAlloca using flexible offset. Or maybe it would make llvm.coro.promise implementation hard or impossible? |
Thanks. I agree your fix is correct.
Some small suggestions commented
llvm/lib/Transforms/Coroutines/CoroFrame.cpp | ||
---|---|---|
2299–2300 | You can move this code to right after "B.addFieldForAllocas(F, FrameData, Shape);" (comments will need to be updated) |
llvm/lib/Transforms/Coroutines/CoroFrame.cpp | ||
---|---|---|
2299–2300 | My first attempt was here. It seems FrameTypeBuilder object is not available here to do the update. |
llvm/lib/Transforms/Coroutines/CoroFrame.cpp | ||
---|---|---|
2299–2300 | Not update here. But move these code to right after "B.addFieldForAllocas(F, FrameData, Shape);" |
llvm/lib/Transforms/Coroutines/CoroFrame.cpp | ||
---|---|---|
2299–2300 | You won't need to update the index manually, if you append the promise alloca to the alloca list after addFieldForAllocas. updateLayoutIndex will take care of it naturally. |
rebase
llvm/lib/Transforms/Coroutines/CoroFrame.cpp | ||
---|---|---|
2299–2300 | Thanks for the explanation! |
PromiseAlloca is added here as a header field, which means it should have a fixed index?
Could it be there are bugs in performOptimizedStructLayout that moved it around somehow?