Skip to content

Commit 483efc9

Browse files
committed
[Pipelines] Remove Legacy Passes in Coroutines
The legacy passes are deprecated now and would be removed in near future. This patch tries to remove legacy passes in coroutines. Reviewed By: aeubanks Differential Revision: https://reviews.llvm.org/D123918
1 parent 5bd8735 commit 483efc9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+35
-737
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
#include "llvm/Support/raw_ostream.h"
5454
#include "llvm/Target/TargetMachine.h"
5555
#include "llvm/Target/TargetOptions.h"
56-
#include "llvm/Transforms/Coroutines.h"
5756
#include "llvm/Transforms/Coroutines/CoroCleanup.h"
5857
#include "llvm/Transforms/Coroutines/CoroEarly.h"
5958
#include "llvm/Transforms/Coroutines/CoroElide.h"

llvm/bindings/go/llvm/transforms_coroutines.go

Lines changed: 0 additions & 23 deletions
This file was deleted.

llvm/bindings/go/llvm/transforms_pmbuilder.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ package llvm
1414

1515
/*
1616
#include "llvm-c/Transforms/PassManagerBuilder.h"
17-
#include "llvm-c/Transforms/Coroutines.h"
1817
*/
1918
import "C"
2019

@@ -62,7 +61,3 @@ func (pmb PassManagerBuilder) SetDisableSimplifyLibCalls(val bool) {
6261
func (pmb PassManagerBuilder) UseInlinerWithThreshold(threshold uint) {
6362
C.LLVMPassManagerBuilderUseInlinerWithThreshold(pmb.C, C.uint(threshold))
6463
}
65-
66-
func (pmb PassManagerBuilder) AddCoroutinePassesToExtensionPoints() {
67-
C.LLVMPassManagerBuilderAddCoroutinePassesToExtensionPoints(pmb.C);
68-
}

llvm/include/llvm-c/Transforms/Coroutines.h

Lines changed: 0 additions & 56 deletions
This file was deleted.

llvm/include/llvm/InitializePasses.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ void initializeInstrumentation(PassRegistry&);
4848
/// Initialize all passes linked into the Analysis library.
4949
void initializeAnalysis(PassRegistry&);
5050

51-
/// Initialize all passes linked into the Coroutines library.
52-
void initializeCoroutines(PassRegistry&);
53-
5451
/// Initialize all passes linked into the CodeGen library.
5552
void initializeCodeGen(PassRegistry&);
5653

llvm/include/llvm/Transforms/Coroutines.h

Lines changed: 0 additions & 37 deletions
This file was deleted.

llvm/lib/Transforms/Coroutines/CoroCleanup.cpp

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -141,41 +141,3 @@ PreservedAnalyses CoroCleanupPass::run(Function &F,
141141

142142
return PreservedAnalyses::none();
143143
}
144-
145-
namespace {
146-
147-
struct CoroCleanupLegacy : FunctionPass {
148-
static char ID; // Pass identification, replacement for typeid
149-
150-
CoroCleanupLegacy() : FunctionPass(ID) {
151-
initializeCoroCleanupLegacyPass(*PassRegistry::getPassRegistry());
152-
}
153-
154-
std::unique_ptr<Lowerer> L;
155-
156-
// This pass has work to do only if we find intrinsics we are going to lower
157-
// in the module.
158-
bool doInitialization(Module &M) override {
159-
if (declaresCoroCleanupIntrinsics(M))
160-
L = std::make_unique<Lowerer>(M);
161-
return false;
162-
}
163-
164-
bool runOnFunction(Function &F) override {
165-
if (L)
166-
return L->lowerRemainingCoroIntrinsics(F);
167-
return false;
168-
}
169-
void getAnalysisUsage(AnalysisUsage &AU) const override {
170-
if (!L)
171-
AU.setPreservesAll();
172-
}
173-
StringRef getPassName() const override { return "Coroutine Cleanup"; }
174-
};
175-
}
176-
177-
char CoroCleanupLegacy::ID = 0;
178-
INITIALIZE_PASS(CoroCleanupLegacy, "coro-cleanup",
179-
"Lower all coroutine related intrinsics", false, false)
180-
181-
Pass *llvm::createCoroCleanupLegacyPass() { return new CoroCleanupLegacy(); }

llvm/lib/Transforms/Coroutines/CoroEarly.cpp

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -256,43 +256,3 @@ PreservedAnalyses CoroEarlyPass::run(Module &M, ModuleAnalysisManager &) {
256256
PA.preserveSet<CFGAnalyses>();
257257
return PA;
258258
}
259-
260-
namespace {
261-
262-
struct CoroEarlyLegacy : public FunctionPass {
263-
static char ID; // Pass identification, replacement for typeid.
264-
CoroEarlyLegacy() : FunctionPass(ID) {
265-
initializeCoroEarlyLegacyPass(*PassRegistry::getPassRegistry());
266-
}
267-
268-
std::unique_ptr<Lowerer> L;
269-
270-
// This pass has work to do only if we find intrinsics we are going to lower
271-
// in the module.
272-
bool doInitialization(Module &M) override {
273-
if (declaresCoroEarlyIntrinsics(M))
274-
L = std::make_unique<Lowerer>(M);
275-
return false;
276-
}
277-
278-
bool runOnFunction(Function &F) override {
279-
if (!L)
280-
return false;
281-
282-
return L->lowerEarlyIntrinsics(F);
283-
}
284-
285-
void getAnalysisUsage(AnalysisUsage &AU) const override {
286-
AU.setPreservesCFG();
287-
}
288-
StringRef getPassName() const override {
289-
return "Lower early coroutine intrinsics";
290-
}
291-
};
292-
}
293-
294-
char CoroEarlyLegacy::ID = 0;
295-
INITIALIZE_PASS(CoroEarlyLegacy, "coro-early",
296-
"Lower early coroutine intrinsics", false, false)
297-
298-
Pass *llvm::createCoroEarlyLegacyPass() { return new CoroEarlyLegacy(); }

llvm/lib/Transforms/Coroutines/CoroElide.cpp

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -370,26 +370,6 @@ bool Lowerer::processCoroId(CoroIdInst *CoroId, AAResults &AA,
370370
return true;
371371
}
372372

373-
// See if there are any coro.subfn.addr instructions referring to coro.devirt
374-
// trigger, if so, replace them with a direct call to devirt trigger function.
375-
static bool replaceDevirtTrigger(Function &F) {
376-
SmallVector<CoroSubFnInst *, 1> DevirtAddr;
377-
for (auto &I : instructions(F))
378-
if (auto *SubFn = dyn_cast<CoroSubFnInst>(&I))
379-
if (SubFn->getIndex() == CoroSubFnInst::RestartTrigger)
380-
DevirtAddr.push_back(SubFn);
381-
382-
if (DevirtAddr.empty())
383-
return false;
384-
385-
Module &M = *F.getParent();
386-
Function *DevirtFn = M.getFunction(CORO_DEVIRT_TRIGGER_FN);
387-
assert(DevirtFn && "coro.devirt.fn not found");
388-
replaceWithConstant(DevirtFn, DevirtAddr);
389-
390-
return true;
391-
}
392-
393373
static bool declaresCoroElideIntrinsics(Module &M) {
394374
return coro::declaresIntrinsics(M, {"llvm.coro.id", "llvm.coro.id.async"});
395375
}
@@ -415,62 +395,3 @@ PreservedAnalyses CoroElidePass::run(Function &F, FunctionAnalysisManager &AM) {
415395

416396
return Changed ? PreservedAnalyses::none() : PreservedAnalyses::all();
417397
}
418-
419-
namespace {
420-
struct CoroElideLegacy : FunctionPass {
421-
static char ID;
422-
CoroElideLegacy() : FunctionPass(ID) {
423-
initializeCoroElideLegacyPass(*PassRegistry::getPassRegistry());
424-
}
425-
426-
std::unique_ptr<Lowerer> L;
427-
428-
bool doInitialization(Module &M) override {
429-
if (declaresCoroElideIntrinsics(M))
430-
L = std::make_unique<Lowerer>(M);
431-
return false;
432-
}
433-
434-
bool runOnFunction(Function &F) override {
435-
if (!L)
436-
return false;
437-
438-
bool Changed = false;
439-
440-
if (F.hasFnAttribute(CORO_PRESPLIT_ATTR))
441-
Changed = replaceDevirtTrigger(F);
442-
443-
L->CoroIds.clear();
444-
L->collectPostSplitCoroIds(&F);
445-
// If we did not find any coro.id, there is nothing to do.
446-
if (L->CoroIds.empty())
447-
return Changed;
448-
449-
AAResults &AA = getAnalysis<AAResultsWrapperPass>().getAAResults();
450-
DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
451-
452-
for (auto *CII : L->CoroIds)
453-
Changed |= L->processCoroId(CII, AA, DT);
454-
455-
return Changed;
456-
}
457-
void getAnalysisUsage(AnalysisUsage &AU) const override {
458-
AU.addRequired<AAResultsWrapperPass>();
459-
AU.addRequired<DominatorTreeWrapperPass>();
460-
}
461-
StringRef getPassName() const override { return "Coroutine Elision"; }
462-
};
463-
}
464-
465-
char CoroElideLegacy::ID = 0;
466-
INITIALIZE_PASS_BEGIN(
467-
CoroElideLegacy, "coro-elide",
468-
"Coroutine frame allocation elision and indirect calls replacement", false,
469-
false)
470-
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
471-
INITIALIZE_PASS_END(
472-
CoroElideLegacy, "coro-elide",
473-
"Coroutine frame allocation elision and indirect calls replacement", false,
474-
false)
475-
476-
Pass *llvm::createCoroElideLegacyPass() { return new CoroElideLegacy(); }

llvm/lib/Transforms/Coroutines/CoroInternal.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,13 @@
1313

1414
#include "CoroInstr.h"
1515
#include "llvm/IR/IRBuilder.h"
16-
#include "llvm/Transforms/Coroutines.h"
1716

1817
namespace llvm {
1918

2019
class CallGraph;
2120
class CallGraphSCC;
2221
class PassRegistry;
2322

24-
void initializeCoroEarlyLegacyPass(PassRegistry &);
25-
void initializeCoroSplitLegacyPass(PassRegistry &);
26-
void initializeCoroElideLegacyPass(PassRegistry &);
27-
void initializeCoroCleanupLegacyPass(PassRegistry &);
28-
2923
// CoroEarly pass marks every function that has coro.begin with a string
3024
// attribute "coroutine.presplit"="0". CoroSplit pass processes the coroutine
3125
// twice. First, it lets it go through complete IPO optimization pipeline as a
@@ -54,8 +48,7 @@ bool declaresAnyIntrinsic(const Module &M);
5448
bool declaresIntrinsics(const Module &M,
5549
const std::initializer_list<StringRef>);
5650
void replaceCoroFree(CoroIdInst *CoroId, bool Elide);
57-
void updateCallGraph(Function &Caller, ArrayRef<Function *> Funcs,
58-
CallGraph &CG, CallGraphSCC &SCC);
51+
5952
/// Recover a dbg.declare prepared by the frontend and emit an alloca
6053
/// holding a pointer to the coroutine frame.
6154
void salvageDebugInfo(

0 commit comments

Comments
 (0)