[llvm] [Coroutines] Refactor CoroShape::buildFrom for future use by ABI objects (PR #108623)
Tyler Nowicki via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 16 15:12:54 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 tidyCoroutine()
+ SmallVector<CoroFrameInst *, 8> CoroFrames;
+ SmallVector<CoroSaveInst *, 2> UnusedCoroSaves;
+
+ // Values invalidated by replaceSwiftErrorOps()
+ SmallVector<CallInst *, 2> SwiftErrorOps;
+
+ void clear() {
+ CoroBegin = nullptr;
+ CoroEnds.clear();
+ CoroSizes.clear();
+ CoroAligns.clear();
+ CoroSuspends.clear();
+ CoroAwaitSuspends.clear();
+ SymmetricTransfers.clear();
+
+ CoroFrames.clear();
+ UnusedCoroSaves.clear();
+
+ SwiftErrorOps.clear();
+
+ FrameTy = nullptr;
+ FramePtr = nullptr;
+ AllocaSpillBlock = nullptr;
+ }
+
+ // Scan the function and collect the above intrinsics for later processing
+ void analyze(Function &F);
+ // If for some reason, we were not able to find coro.begin, bailout.
+ void invalidateCoroutine(Function &F);
+ // Perform ABI related initial transformation
+ void initABI();
+ // Remove orphaned and unnecessary intrinsics
+ void tidyCoroutine();
----------------
TylerNowicki wrote:
Done
https://github.com/llvm/llvm-project/pull/108623
More information about the llvm-commits
mailing list