[llvm] [Coroutines] Refactor CoroShape::buildFrom for future use by ABI objects (PR #108623)

Chuanqi Xu via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 18 19:19:16 PDT 2024


================
@@ -50,15 +50,49 @@ enum class ABI {
 // Holds structural Coroutine Intrinsics for a particular function and other
 // values used during CoroSplit pass.
 struct LLVM_LIBRARY_VISIBILITY Shape {
-  CoroBeginInst *CoroBegin;
+  CoroBeginInst *CoroBegin = nullptr;
   SmallVector<AnyCoroEndInst *, 4> CoroEnds;
   SmallVector<CoroSizeInst *, 2> CoroSizes;
   SmallVector<CoroAlignInst *, 2> CoroAligns;
   SmallVector<AnyCoroSuspendInst *, 4> CoroSuspends;
-  SmallVector<CallInst *, 2> SwiftErrorOps;
   SmallVector<CoroAwaitSuspendInst *, 4> CoroAwaitSuspends;
   SmallVector<CallInst *, 2> SymmetricTransfers;
 
+  // Values invalidated by invalidateCoroutine() and cleanCoroutine()
+  SmallVector<CoroFrameInst *, 8> CoroFrames;
+  SmallVector<CoroSaveInst *, 2> UnusedCoroSaves;
----------------
ChuanqiXu9 wrote:

> I see you approved the change but I don't see a lgtm? Do you want me to make these nit changes in another patch?

Approve with a nit means, you can land it as if now, but I'll be more happier if you address the nit comments.

> 1. Keep CoroShape::CoroFrames and CoroShape::UnusedCoroSaves

I mean, keep them as is, a local variables, IIUC.

> My original intent to the changes was to ensure that we could create CoroShape objects from the Function without changing the Function's instructions in anyway. 

The idea sounds good. But it will erase the instructions, right? I don't feel bad with this since this is the current behavior of the building process of CoroShape. But it will be good to make it a pure analysis process.

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


More information about the llvm-commits mailing list