[llvm] r277033 - [coroutines] Part 3 of N: Adding Boilerplate for Coroutine Passes
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 28 14:04:32 PDT 2016
Author: majnemer
Date: Thu Jul 28 16:04:31 2016
New Revision: 277033
URL: http://llvm.org/viewvc/llvm-project?rev=277033&view=rev
Log:
[coroutines] Part 3 of N: Adding Boilerplate for Coroutine Passes
This adds boilerplate code for all coroutine passes,
the passes are no-ops for now.
Also, a small test has been added to verify that passes execute in
the expected order or not at all if coroutine support is disabled.
Patch by Gor Nishanov!
Differential Revision: https://reviews.llvm.org/D22847
Added:
llvm/trunk/include/llvm/Transforms/Coroutines.h
llvm/trunk/lib/Transforms/Coroutines/
llvm/trunk/lib/Transforms/Coroutines/CMakeLists.txt
llvm/trunk/lib/Transforms/Coroutines/CoroCleanup.cpp
llvm/trunk/lib/Transforms/Coroutines/CoroEarly.cpp
llvm/trunk/lib/Transforms/Coroutines/CoroElide.cpp
llvm/trunk/lib/Transforms/Coroutines/CoroInternal.h
llvm/trunk/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/trunk/lib/Transforms/Coroutines/Coroutines.cpp
llvm/trunk/lib/Transforms/Coroutines/LLVMBuild.txt
- copied, changed from r277032, llvm/trunk/lib/Transforms/LLVMBuild.txt
llvm/trunk/test/Transforms/Coroutines/
llvm/trunk/test/Transforms/Coroutines/smoketest.ll
Modified:
llvm/trunk/docs/Coroutines.rst
llvm/trunk/include/llvm/InitializePasses.h
llvm/trunk/lib/Transforms/CMakeLists.txt
llvm/trunk/lib/Transforms/LLVMBuild.txt
llvm/trunk/tools/opt/CMakeLists.txt
llvm/trunk/tools/opt/opt.cpp
Modified: llvm/trunk/docs/Coroutines.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/Coroutines.rst?rev=277033&r1=277032&r2=277033&view=diff
==============================================================================
--- llvm/trunk/docs/Coroutines.rst (original)
+++ llvm/trunk/docs/Coroutines.rst Thu Jul 28 16:04:31 2016
@@ -1177,8 +1177,8 @@ earlier passes.
Upstreaming sequence (rough plan)
=================================
#. Add documentation.
-#. Add coroutine intrinsics. <= we are here
-#. Add empty coroutine passes.
+#. Add coroutine intrinsics.
+#. Add empty coroutine passes. <= we are here
#. Add coroutine devirtualization + tests.
#. Add CGSCC restart trigger + tests.
#. Add coroutine heap elision + tests.
Modified: llvm/trunk/include/llvm/InitializePasses.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/InitializePasses.h?rev=277033&r1=277032&r2=277033&view=diff
==============================================================================
--- llvm/trunk/include/llvm/InitializePasses.h (original)
+++ llvm/trunk/include/llvm/InitializePasses.h Thu Jul 28 16:04:31 2016
@@ -46,6 +46,9 @@ void initializeInstrumentation(PassRegis
/// Initialize all passes linked into the Analysis library.
void initializeAnalysis(PassRegistry&);
+/// Initialize all passes linked into the Coroutines library.
+void initializeCoroutines(PassRegistry&);
+
/// Initialize all passes linked into the CodeGen library.
void initializeCodeGen(PassRegistry&);
Added: llvm/trunk/include/llvm/Transforms/Coroutines.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Coroutines.h?rev=277033&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Transforms/Coroutines.h (added)
+++ llvm/trunk/include/llvm/Transforms/Coroutines.h Thu Jul 28 16:04:31 2016
@@ -0,0 +1,38 @@
+//===-- Coroutines.h - Coroutine Transformations ----------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Declare accessor functions for coroutine lowering passes.
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TRANSFORMS_COROUTINES_H
+#define LLVM_TRANSFORMS_COROUTINES_H
+
+namespace llvm {
+
+class Pass;
+class PassManagerBuilder;
+
+/// Add all coroutine passes to appropriate extension points.
+void addCoroutinePassesToExtensionPoints(PassManagerBuilder &Builder);
+
+/// Lower coroutine intrinsics that are not needed by later passes.
+Pass *createCoroEarlyPass();
+
+/// Split up coroutines into multiple functions driving their state machines.
+Pass *createCoroSplitPass();
+
+/// Analyze coroutines use sites, devirtualize resume/destroy calls and elide
+/// heap allocation for coroutine frame where possible.
+Pass *createCoroElidePass();
+
+/// Lower all remaining coroutine intrinsics.
+Pass *createCoroCleanupPass();
+
+}
+
+#endif
Modified: llvm/trunk/lib/Transforms/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/CMakeLists.txt?rev=277033&r1=277032&r2=277033&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/CMakeLists.txt (original)
+++ llvm/trunk/lib/Transforms/CMakeLists.txt Thu Jul 28 16:04:31 2016
@@ -6,3 +6,4 @@ add_subdirectory(IPO)
add_subdirectory(Vectorize)
add_subdirectory(Hello)
add_subdirectory(ObjCARC)
+add_subdirectory(Coroutines)
Added: llvm/trunk/lib/Transforms/Coroutines/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Coroutines/CMakeLists.txt?rev=277033&view=auto
==============================================================================
--- llvm/trunk/lib/Transforms/Coroutines/CMakeLists.txt (added)
+++ llvm/trunk/lib/Transforms/Coroutines/CMakeLists.txt Thu Jul 28 16:04:31 2016
@@ -0,0 +1,8 @@
+add_llvm_library(LLVMCoroutines
+ Coroutines.cpp
+ CoroCleanup.cpp
+ CoroEarly.cpp
+ CoroElide.cpp
+ CoroSplit.cpp
+ )
+
Added: llvm/trunk/lib/Transforms/Coroutines/CoroCleanup.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Coroutines/CoroCleanup.cpp?rev=277033&view=auto
==============================================================================
--- llvm/trunk/lib/Transforms/Coroutines/CoroCleanup.cpp (added)
+++ llvm/trunk/lib/Transforms/Coroutines/CoroCleanup.cpp Thu Jul 28 16:04:31 2016
@@ -0,0 +1,42 @@
+//===- CoroCleanup.cpp - Coroutine Cleanup Pass ---------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// This pass lowers all remaining coroutine intrinsics.
+//===----------------------------------------------------------------------===//
+
+#include "CoroInternal.h"
+#include "llvm/Pass.h"
+
+using namespace llvm;
+
+#define DEBUG_TYPE "coro-cleanup"
+
+//===----------------------------------------------------------------------===//
+// Top Level Driver
+//===----------------------------------------------------------------------===//
+
+namespace {
+
+struct CoroCleanup : FunctionPass {
+ static char ID; // Pass identification, replacement for typeid
+
+ CoroCleanup() : FunctionPass(ID) {}
+
+ bool runOnFunction(Function &F) override { return false; }
+ void getAnalysisUsage(AnalysisUsage &AU) const override {
+ AU.setPreservesAll();
+ }
+};
+
+}
+
+char CoroCleanup::ID = 0;
+INITIALIZE_PASS(CoroCleanup, "coro-cleanup",
+ "Lower all coroutine related intrinsics", false, false)
+
+Pass *llvm::createCoroCleanupPass() { return new CoroCleanup(); }
Added: llvm/trunk/lib/Transforms/Coroutines/CoroEarly.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Coroutines/CoroEarly.cpp?rev=277033&view=auto
==============================================================================
--- llvm/trunk/lib/Transforms/Coroutines/CoroEarly.cpp (added)
+++ llvm/trunk/lib/Transforms/Coroutines/CoroEarly.cpp Thu Jul 28 16:04:31 2016
@@ -0,0 +1,43 @@
+//===- CoroEarly.cpp - Coroutine Early Function Pass ----------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// This pass lowers coroutine intrinsics that hide the details of the exact
+// calling convention for coroutine resume and destroy functions and details of
+// the structure of the coroutine frame.
+//===----------------------------------------------------------------------===//
+
+#include "CoroInternal.h"
+#include "llvm/Pass.h"
+
+using namespace llvm;
+
+#define DEBUG_TYPE "coro-early"
+
+//===----------------------------------------------------------------------===//
+// Top Level Driver
+//===----------------------------------------------------------------------===//
+
+namespace {
+
+struct CoroEarly : public FunctionPass {
+ static char ID; // Pass identification, replacement for typeid
+ CoroEarly() : FunctionPass(ID) {}
+
+ bool runOnFunction(Function &F) override { return false; }
+ void getAnalysisUsage(AnalysisUsage &AU) const override {
+ AU.setPreservesAll();
+ }
+};
+
+}
+
+char CoroEarly::ID = 0;
+INITIALIZE_PASS(CoroEarly, "coro-early", "Lower early coroutine intrinsics",
+ false, false)
+
+Pass *llvm::createCoroEarlyPass() { return new CoroEarly(); }
Added: llvm/trunk/lib/Transforms/Coroutines/CoroElide.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Coroutines/CoroElide.cpp?rev=277033&view=auto
==============================================================================
--- llvm/trunk/lib/Transforms/Coroutines/CoroElide.cpp (added)
+++ llvm/trunk/lib/Transforms/Coroutines/CoroElide.cpp Thu Jul 28 16:04:31 2016
@@ -0,0 +1,49 @@
+//===- CoroElide.cpp - Coroutine Frame Allocation Elision Pass ------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// This pass replaces dynamic allocation of coroutine frame with alloca and
+// replaces calls to llvm.coro.resume and llvm.coro.destroy with direct calls
+// to coroutine sub-functions.
+//===----------------------------------------------------------------------===//
+
+#include "CoroInternal.h"
+#include "llvm/Analysis/AliasAnalysis.h"
+#include "llvm/Pass.h"
+
+using namespace llvm;
+
+#define DEBUG_TYPE "coro-elide"
+
+//===----------------------------------------------------------------------===//
+// Top Level Driver
+//===----------------------------------------------------------------------===//
+
+namespace {
+
+struct CoroElide : FunctionPass {
+ static char ID;
+ CoroElide() : FunctionPass(ID) {}
+ bool runOnFunction(Function &F) override { return false; }
+ void getAnalysisUsage(AnalysisUsage &AU) const override {
+ AU.setPreservesAll();
+ }
+};
+
+}
+
+char CoroElide::ID = 0;
+INITIALIZE_PASS_BEGIN(
+ CoroElide, "coro-elide",
+ "Coroutine frame allocation elision and indirect calls replacement", false,
+ false)
+INITIALIZE_PASS_END(
+ CoroElide, "coro-elide",
+ "Coroutine frame allocation elision and indirect calls replacement", false,
+ false)
+
+Pass *llvm::createCoroElidePass() { return new CoroElide(); }
Added: llvm/trunk/lib/Transforms/Coroutines/CoroInternal.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Coroutines/CoroInternal.h?rev=277033&view=auto
==============================================================================
--- llvm/trunk/lib/Transforms/Coroutines/CoroInternal.h (added)
+++ llvm/trunk/lib/Transforms/Coroutines/CoroInternal.h Thu Jul 28 16:04:31 2016
@@ -0,0 +1,28 @@
+//===- CoroInternal.h - Internal Coroutine interfaces ---------*- C++ -*---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// Common definitions/declarations used internally by coroutine lowering passes.
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIB_TRANSFORMS_COROUTINES_COROINTERNAL_H
+#define LLVM_LIB_TRANSFORMS_COROUTINES_COROINTERNAL_H
+
+#include "llvm/Transforms/Coroutines.h"
+
+namespace llvm {
+
+class PassRegistry;
+
+void initializeCoroEarlyPass(PassRegistry &);
+void initializeCoroSplitPass(PassRegistry &);
+void initializeCoroElidePass(PassRegistry &);
+void initializeCoroCleanupPass(PassRegistry &);
+
+}
+
+#endif
Added: llvm/trunk/lib/Transforms/Coroutines/CoroSplit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Coroutines/CoroSplit.cpp?rev=277033&view=auto
==============================================================================
--- llvm/trunk/lib/Transforms/Coroutines/CoroSplit.cpp (added)
+++ llvm/trunk/lib/Transforms/Coroutines/CoroSplit.cpp Thu Jul 28 16:04:31 2016
@@ -0,0 +1,45 @@
+//===- CoroSplit.cpp - Converts a coroutine into a state machine ----------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// This pass builds the coroutine frame and outlines resume and destroy parts
+// of the coroutine into separate functions.
+//===----------------------------------------------------------------------===//
+
+#include "CoroInternal.h"
+#include "llvm/Analysis/CallGraphSCCPass.h"
+
+using namespace llvm;
+
+#define DEBUG_TYPE "coro-split"
+
+//===----------------------------------------------------------------------===//
+// Top Level Driver
+//===----------------------------------------------------------------------===//
+
+namespace {
+
+struct CoroSplit : public CallGraphSCCPass {
+ static char ID; // Pass identification, replacement for typeid
+ CoroSplit() : CallGraphSCCPass(ID) {}
+
+ bool runOnSCC(CallGraphSCC &SCC) override { return false; }
+ void getAnalysisUsage(AnalysisUsage &AU) const override {
+ AU.setPreservesAll();
+ CallGraphSCCPass::getAnalysisUsage(AU);
+ }
+};
+
+}
+
+char CoroSplit::ID = 0;
+INITIALIZE_PASS(
+ CoroSplit, "coro-split",
+ "Split coroutine into a set of functions driving its state machine", false,
+ false)
+
+Pass *llvm::createCoroSplitPass() { return new CoroSplit(); }
Added: llvm/trunk/lib/Transforms/Coroutines/Coroutines.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Coroutines/Coroutines.cpp?rev=277033&view=auto
==============================================================================
--- llvm/trunk/lib/Transforms/Coroutines/Coroutines.cpp (added)
+++ llvm/trunk/lib/Transforms/Coroutines/Coroutines.cpp Thu Jul 28 16:04:31 2016
@@ -0,0 +1,68 @@
+//===-- Coroutines.cpp ----------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+// This file implements the common infrastructure for Coroutine Passes.
+//===----------------------------------------------------------------------===//
+
+#include "CoroInternal.h"
+#include "llvm/IR/LegacyPassManager.h"
+#include "llvm/IR/Verifier.h"
+#include "llvm/InitializePasses.h"
+#include "llvm/Transforms/IPO.h"
+#include "llvm/Transforms/IPO/PassManagerBuilder.h"
+
+using namespace llvm;
+
+void llvm::initializeCoroutines(PassRegistry &Registry) {
+ initializeCoroEarlyPass(Registry);
+ initializeCoroSplitPass(Registry);
+ initializeCoroElidePass(Registry);
+ initializeCoroCleanupPass(Registry);
+}
+
+static void addCoroutineOpt0Passes(const PassManagerBuilder &Builder,
+ legacy::PassManagerBase &PM) {
+ PM.add(createCoroSplitPass());
+ PM.add(createCoroElidePass());
+
+ PM.add(createBarrierNoopPass());
+ PM.add(createCoroCleanupPass());
+}
+
+static void addCoroutineEarlyPasses(const PassManagerBuilder &Builder,
+ legacy::PassManagerBase &PM) {
+ PM.add(createCoroEarlyPass());
+}
+
+static void addCoroutineScalarOptimizerPasses(const PassManagerBuilder &Builder,
+ legacy::PassManagerBase &PM) {
+ PM.add(createCoroElidePass());
+}
+
+static void addCoroutineSCCPasses(const PassManagerBuilder &Builder,
+ legacy::PassManagerBase &PM) {
+ PM.add(createCoroSplitPass());
+}
+
+static void addCoroutineOptimizerLastPasses(const PassManagerBuilder &Builder,
+ legacy::PassManagerBase &PM) {
+ PM.add(createCoroCleanupPass());
+}
+
+void llvm::addCoroutinePassesToExtensionPoints(PassManagerBuilder &Builder) {
+ Builder.addExtension(PassManagerBuilder::EP_EarlyAsPossible,
+ addCoroutineEarlyPasses);
+ Builder.addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
+ addCoroutineOpt0Passes);
+ Builder.addExtension(PassManagerBuilder::EP_CGSCCOptimizerLate,
+ addCoroutineSCCPasses);
+ Builder.addExtension(PassManagerBuilder::EP_ScalarOptimizerLate,
+ addCoroutineScalarOptimizerPasses);
+ Builder.addExtension(PassManagerBuilder::EP_OptimizerLast,
+ addCoroutineOptimizerLastPasses);
+}
Copied: llvm/trunk/lib/Transforms/Coroutines/LLVMBuild.txt (from r277032, llvm/trunk/lib/Transforms/LLVMBuild.txt)
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Coroutines/LLVMBuild.txt?p2=llvm/trunk/lib/Transforms/Coroutines/LLVMBuild.txt&p1=llvm/trunk/lib/Transforms/LLVMBuild.txt&r1=277032&r2=277033&rev=277033&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Transforms/Coroutines/LLVMBuild.txt Thu Jul 28 16:04:31 2016
@@ -1,4 +1,4 @@
-;===- ./lib/Transforms/LLVMBuild.txt ---------------------------*- Conf -*--===;
+;===- ./lib/Transforms/Coroutines/LLVMBuild.txt ----------------*- Conf -*--===;
;
; The LLVM Compiler Infrastructure
;
@@ -15,10 +15,8 @@
;
;===------------------------------------------------------------------------===;
-[common]
-subdirectories = IPO InstCombine Instrumentation Scalar Utils Vectorize ObjCARC
-
[component_0]
-type = Group
-name = Transforms
-parent = Libraries
+type = Library
+name = Coroutines
+parent = Transforms
+required_libraries = Analysis Core IPO Scalar Support TransformUtils
Modified: llvm/trunk/lib/Transforms/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/LLVMBuild.txt?rev=277033&r1=277032&r2=277033&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Transforms/LLVMBuild.txt Thu Jul 28 16:04:31 2016
@@ -16,7 +16,7 @@
;===------------------------------------------------------------------------===;
[common]
-subdirectories = IPO InstCombine Instrumentation Scalar Utils Vectorize ObjCARC
+subdirectories = Coroutines IPO InstCombine Instrumentation Scalar Utils Vectorize ObjCARC
[component_0]
type = Group
Added: llvm/trunk/test/Transforms/Coroutines/smoketest.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Coroutines/smoketest.ll?rev=277033&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/Coroutines/smoketest.ll (added)
+++ llvm/trunk/test/Transforms/Coroutines/smoketest.ll Thu Jul 28 16:04:31 2016
@@ -0,0 +1,24 @@
+; Test that all coroutine passes run in the correct order at all optimization
+; levels and -disable-coroutines removes coroutine passes from the pipeline.
+;
+; RUN: opt < %s -disable-output -enable-coroutines -debug-pass=Arguments -O1 2>&1 | FileCheck %s
+; RUN: opt < %s -disable-output -enable-coroutines -debug-pass=Arguments -O2 2>&1 | FileCheck %s
+; RUN: opt < %s -disable-output -enable-coroutines -debug-pass=Arguments -O3 2>&1 | FileCheck %s
+; RUN: opt < %s -disable-output -enable-coroutines -debug-pass=Arguments \
+; RUN: -coro-early -coro-split -coro-elide -coro-cleanup 2>&1 | FileCheck %s
+; RUN: opt < %s -disable-output -debug-pass=Arguments 2>&1 \
+; RUN: | FileCheck %s -check-prefix=NOCORO
+
+; CHECK: coro-early
+; CHECK: coro-split
+; CHECK: coro-elide
+; CHECK: coro-cleanup
+
+; NOCORO-NOT: coro-early
+; NOCORO-NOT: coro-split
+; NOCORO-NOT: coro-elide
+; NOCORO-NOT: coro-cleanup
+
+define void @foo() {
+ ret void
+}
Modified: llvm/trunk/tools/opt/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/CMakeLists.txt?rev=277033&r1=277032&r2=277033&view=diff
==============================================================================
--- llvm/trunk/tools/opt/CMakeLists.txt (original)
+++ llvm/trunk/tools/opt/CMakeLists.txt Thu Jul 28 16:04:31 2016
@@ -4,6 +4,7 @@ set(LLVM_LINK_COMPONENTS
BitWriter
CodeGen
Core
+ Coroutines
IPO
IRReader
InstCombine
Modified: llvm/trunk/tools/opt/opt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=277033&r1=277032&r2=277033&view=diff
==============================================================================
--- llvm/trunk/tools/opt/opt.cpp (original)
+++ llvm/trunk/tools/opt/opt.cpp Thu Jul 28 16:04:31 2016
@@ -50,6 +50,7 @@
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Target/TargetMachine.h"
+#include "llvm/Transforms/Coroutines.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include <algorithm>
@@ -215,6 +216,11 @@ static cl::opt<bool> DiscardValueNames(
cl::desc("Discard names from Value (other than GlobalValue)."),
cl::init(false), cl::Hidden);
+static cl::opt<bool> Coroutines(
+ "enable-coroutines",
+ cl::desc("Enable coroutine passes."),
+ cl::init(false), cl::Hidden);
+
static cl::opt<bool> PassRemarksWithHotness(
"pass-remarks-with-hotness",
cl::desc("With PGO, include profile count in optimization remarks"),
@@ -274,6 +280,9 @@ static void AddOptimizationPasses(legacy
TM->addEarlyAsPossiblePasses(PM);
});
+ if (Coroutines)
+ addCoroutinePassesToExtensionPoints(Builder);
+
Builder.populateFunctionPassManager(FPM);
Builder.populateModulePassManager(MPM);
}
@@ -348,6 +357,7 @@ int main(int argc, char **argv) {
// Initialize passes
PassRegistry &Registry = *PassRegistry::getPassRegistry();
initializeCore(Registry);
+ initializeCoroutines(Registry);
initializeScalarOpts(Registry);
initializeObjCARCOpts(Registry);
initializeVectorization(Registry);
More information about the llvm-commits
mailing list