[PATCH] D94258: [CoroSplit][NewPM] Don't call LazyCallGraph functions to split when no clones

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 7 12:48:06 PST 2021


aeubanks created this revision.
Herald added subscribers: lxfind, hiraditya.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Apparently there can be no clones, as happens in
coro-retcon-unreachable.ll.

The alternative is to allow no split functions in
addSplitRefRecursiveFunctions(), but it seems better to have the caller
make sure it's not accidentally splitting no functions out.

Depends on D94257 <https://reviews.llvm.org/D94257>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D94258

Files:
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll


Index: llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll
===================================================================
--- llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll
+++ llvm/test/Transforms/Coroutines/coro-retcon-unreachable.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s -coro-early -coro-split -S | FileCheck %s
+; RUN: opt < %s -passes='function(coro-early),cgscc(coro-split)' -S | FileCheck %s
 target datalayout = "E-p:64:64"
 
 %swift.type = type { i64 }
Index: llvm/lib/Transforms/Coroutines/CoroSplit.cpp
===================================================================
--- llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -1748,24 +1748,26 @@
     End->eraseFromParent();
   }
 
-  switch (Shape.ABI) {
-  case coro::ABI::Switch:
-    // Each clone in the Switch lowering is independent of the other clones. Let
-    // the LazyCallGraph know about each one separately.
-    for (Function *Clone : Clones)
-      CG.addSplitFunction(N.getFunction(), *Clone);
-    break;
-  case coro::ABI::Async:
-  case coro::ABI::Retcon:
-  case coro::ABI::RetconOnce:
-    // Each clone in the Async/Retcon lowering references of the other clones.
-    // Let the LazyCallGraph know about all of them at once.
-    CG.addSplitRefRecursiveFunctions(N.getFunction(), Clones);
-    break;
-  }
+  if (!Clones.empty()) {
+    switch (Shape.ABI) {
+    case coro::ABI::Switch:
+      // Each clone in the Switch lowering is independent of the other clones.
+      // Let the LazyCallGraph know about each one separately.
+      for (Function *Clone : Clones)
+        CG.addSplitFunction(N.getFunction(), *Clone);
+      break;
+    case coro::ABI::Async:
+    case coro::ABI::Retcon:
+    case coro::ABI::RetconOnce:
+      // Each clone in the Async/Retcon lowering references of the other clones.
+      // Let the LazyCallGraph know about all of them at once.
+      CG.addSplitRefRecursiveFunctions(N.getFunction(), Clones);
+      break;
+    }
 
-  // Let the CGSCC infra handle the changes to the original function.
-  updateCGAndAnalysisManagerForCGSCCPass(CG, C, N, AM, UR, FAM);
+    // Let the CGSCC infra handle the changes to the original function.
+    updateCGAndAnalysisManagerForCGSCCPass(CG, C, N, AM, UR, FAM);
+  }
 
   // Do some cleanup and let the CGSCC infra see if we've cleaned up any edges
   // to the split functions.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94258.315215.patch
Type: text/x-patch
Size: 2411 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210107/66453ac0/attachment.bin>


More information about the llvm-commits mailing list