[llvm] 902f470 - [NFC] [Coroutines] Remove unnecessary check and constraints on SmallVector

Chuanqi Xu via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 21 23:26:53 PDT 2022


Author: Chuanqi Xu
Date: 2022-03-22T14:24:46+08:00
New Revision: 902f4708fe1d03b0de7e5315ef875006a6adc319

URL: https://github.com/llvm/llvm-project/commit/902f4708fe1d03b0de7e5315ef875006a6adc319
DIFF: https://github.com/llvm/llvm-project/commit/902f4708fe1d03b0de7e5315ef875006a6adc319.diff

LOG: [NFC] [Coroutines] Remove unnecessary check and constraints on SmallVector

The CoroSplit pass would check the existence of coroutine intrinsic
before starting work. It is not necessary and wasteful since it would
iterate over the Module.

This patch also removes the constraint on the corresponding of the
SmallVector for the possible coroutines in the Modules. The original
value is 4. Given coroutines is used actually in practice. 4 is really
relatively a low threshold.

Added: 
    

Modified: 
    llvm/lib/Transforms/Coroutines/CoroSplit.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index a9e224fc923fa..89b40a377ad7e 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -2210,16 +2210,13 @@ PreservedAnalyses CoroSplitPass::run(LazyCallGraph::SCC &C,
   auto &FAM =
       AM.getResult<FunctionAnalysisManagerCGSCCProxy>(C, CG).getManager();
 
-  if (!declaresCoroSplitIntrinsics(M))
-    return PreservedAnalyses::all();
-
   // Check for uses of llvm.coro.prepare.retcon/async.
   SmallVector<Function *, 2> PrepareFns;
   addPrepareFunction(M, PrepareFns, "llvm.coro.prepare.retcon");
   addPrepareFunction(M, PrepareFns, "llvm.coro.prepare.async");
 
   // Find coroutines for processing.
-  SmallVector<LazyCallGraph::Node *, 4> Coroutines;
+  SmallVector<LazyCallGraph::Node *> Coroutines;
   for (LazyCallGraph::Node &N : C)
     if (N.getFunction().hasFnAttribute(CORO_PRESPLIT_ATTR))
       Coroutines.push_back(&N);


        


More information about the llvm-commits mailing list