| 1 | //===- CoroConditionalWrapper.cpp -----------------------------------------===// |
|---|---|
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "llvm/Transforms/Coroutines/CoroConditionalWrapper.h" |
| 10 | #include "CoroInternal.h" |
| 11 | #include "llvm/IR/Module.h" |
| 12 | |
| 13 | using namespace llvm; |
| 14 | |
| 15 | CoroConditionalWrapper::CoroConditionalWrapper(ModulePassManager &&PM) |
| 16 | : PM(std::move(PM)) {} |
| 17 | |
| 18 | PreservedAnalyses CoroConditionalWrapper::run(Module &M, |
| 19 | ModuleAnalysisManager &AM) { |
| 20 | if (!coro::declaresAnyIntrinsic(M)) |
| 21 | return PreservedAnalyses::all(); |
| 22 | |
| 23 | return PM.run(IR&: M, AM); |
| 24 | } |
| 25 | |
| 26 | void CoroConditionalWrapper::printPipeline( |
| 27 | raw_ostream &OS, function_ref<StringRef(StringRef)> MapClassName2PassName) { |
| 28 | OS << "coro-cond"; |
| 29 | OS << '('; |
| 30 | PM.printPipeline(OS, MapClassName2PassName); |
| 31 | OS << ')'; |
| 32 | } |
| 33 |