[PATCH] D23461: [Coroutines] Part 7: Split coroutine into subfunctions

Gor Nishanov via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 12 16:51:11 PDT 2016


GorNishanov marked 9 inline comments as done.

================
Comment at: lib/Transforms/Coroutines/CoroCleanup.cpp:30-37
@@ +29,10 @@
+
+static void simplifyCFG(Function &F) {
+  llvm::legacy::FunctionPassManager FPM(F.getParent());
+  FPM.add(createCFGSimplificationPass());
+
+  FPM.doInitialization();
+  FPM.run(F);
+  FPM.doFinalization();
+}
+
----------------
majnemer wrote:
> I'd just make `simplifyFunctionCFG` a non-internal function and call it instead of making a new FPM.
We may end up needed more cleanup passes there. I'll keep at is as is for now.

================
Comment at: lib/Transforms/Coroutines/CoroCleanup.cpp:44
@@ +43,3 @@
+    Instruction &I = *IB++;
+    if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(&I)) {
+      switch (II->getIntrinsicID()) {
----------------
majnemer wrote:
> majnemer wrote:
> > `auto *`
> Should this be a `CallSite` instead?
The only throwing coroutine intrinsics are coro.resume and coro.destroy are lowered in coro.early. 

================
Comment at: lib/Transforms/Coroutines/CoroFrame.cpp:63-66
@@ +62,6 @@
+  StructType *FrameTy = StructType::create(C, Name);
+  auto FramePtrTy = FrameTy->getPointerTo();
+  auto FnTy = FunctionType::get(Type::getVoidTy(C), FramePtrTy,
+                                /*IsVarArgs=*/false);
+  auto FnPtrTy = FnTy->getPointerTo();
+
----------------
majnemer wrote:
> `auto *`
Missed those. Will upload in a sec.

================
Comment at: lib/Transforms/Coroutines/Coroutines.cpp:196
@@ +195,3 @@
+  for (auto IB = inst_begin(F), IE = inst_end(F); IB != IE;) {
+    if (auto II = dyn_cast<IntrinsicInst>(&*IB++)) {
+      switch (II->getIntrinsicID()) {
----------------
majnemer wrote:
> `auto *` although maybe we should use a CallSite?
Only coro.resume and coro.destroy are throwing and they are replaced by CoroEarly Pass.


https://reviews.llvm.org/D23461





More information about the llvm-commits mailing list