@@ -58,10 +58,6 @@ struct LLVM_LIBRARY_VISIBILITY Shape {
58
58
SmallVector<CoroAwaitSuspendInst *, 4 > CoroAwaitSuspends;
59
59
SmallVector<CallInst *, 2 > SymmetricTransfers;
60
60
61
- // Values invalidated by invalidateCoroutine() and cleanCoroutine()
62
- SmallVector<CoroFrameInst *, 8 > CoroFrames;
63
- SmallVector<CoroSaveInst *, 2 > UnusedCoroSaves;
64
-
65
61
// Values invalidated by replaceSwiftErrorOps()
66
62
SmallVector<CallInst *, 2 > SwiftErrorOps;
67
63
@@ -74,9 +70,6 @@ struct LLVM_LIBRARY_VISIBILITY Shape {
74
70
CoroAwaitSuspends.clear ();
75
71
SymmetricTransfers.clear ();
76
72
77
- CoroFrames.clear ();
78
- UnusedCoroSaves.clear ();
79
-
80
73
SwiftErrorOps.clear ();
81
74
82
75
FrameTy = nullptr ;
@@ -85,13 +78,16 @@ struct LLVM_LIBRARY_VISIBILITY Shape {
85
78
}
86
79
87
80
// Scan the function and collect the above intrinsics for later processing
88
- void analyze (Function &F);
81
+ void analyze (Function &F, SmallVectorImpl<CoroFrameInst *> &CoroFrames,
82
+ SmallVectorImpl<CoroSaveInst *> &UnusedCoroSaves);
89
83
// If for some reason, we were not able to find coro.begin, bailout.
90
- void invalidateCoroutine (Function &F);
84
+ void invalidateCoroutine (Function &F,
85
+ SmallVectorImpl<CoroFrameInst *> &CoroFrames);
91
86
// Perform ABI related initial transformation
92
87
void initABI ();
93
88
// Remove orphaned and unnecessary intrinsics
94
- void cleanCoroutine ();
89
+ void cleanCoroutine (SmallVectorImpl<CoroFrameInst *> &CoroFrames,
90
+ SmallVectorImpl<CoroSaveInst *> &UnusedCoroSaves);
95
91
96
92
// Field indexes for special fields in the switch lowering.
97
93
struct SwitchFieldIndex {
@@ -271,13 +267,16 @@ struct LLVM_LIBRARY_VISIBILITY Shape {
271
267
Shape () = default ;
272
268
explicit Shape (Function &F, bool OptimizeFrame = false )
273
269
: OptimizeFrame(OptimizeFrame) {
274
- analyze (F);
270
+ SmallVector<CoroFrameInst *, 8 > CoroFrames;
271
+ SmallVector<CoroSaveInst *, 2 > UnusedCoroSaves;
272
+
273
+ analyze (F, CoroFrames, UnusedCoroSaves);
275
274
if (!CoroBegin) {
276
- invalidateCoroutine (F);
275
+ invalidateCoroutine (F, CoroFrames );
277
276
return ;
278
277
}
279
278
initABI ();
280
- cleanCoroutine ();
279
+ cleanCoroutine (CoroFrames, UnusedCoroSaves );
281
280
}
282
281
};
283
282
0 commit comments