Skip to content

Commit 44ee9d0

Browse files
committed
Revert D85812 "[coroutine] should disable inline before calling coro split"
This reverts commit 2e43acf. LLVMCoroutines (the library which contains Coroutines.h) depends on LLVMipo (the library which contains SampleProfile.cpp). It is inappropriate for SampleProfile.cpp to depent on Coroutines.h (circular dependency). The test inverted dependencies as well: llvm/test/Transforms/Coroutines/coro-inline.ll uses -sample-profile.
1 parent 75e6f0b commit 44ee9d0

File tree

6 files changed

+14
-86
lines changed

6 files changed

+14
-86
lines changed

llvm/include/llvm/Transforms/Coroutines.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@
1313

1414
namespace llvm {
1515

16-
// CoroEarly pass marks every function that has coro.begin with a string
17-
// attribute "coroutine.presplit"="0". CoroSplit pass processes the coroutine
18-
// twice. First, it lets it go through complete IPO optimization pipeline as a
19-
// single function. It forces restart of the pipeline by inserting an indirect
20-
// call to an empty function "coro.devirt.trigger" which is devirtualized by
21-
// CoroElide pass that triggers a restart of the pipeline by CGPassManager.
22-
// When CoroSplit pass sees the same coroutine the second time, it splits it up,
23-
// adds coroutine subfunctions to the SCC to be processed by IPO pipeline.
24-
#define CORO_PRESPLIT_ATTR "coroutine.presplit"
25-
#define UNPREPARED_FOR_SPLIT "0"
26-
#define PREPARED_FOR_SPLIT "1"
27-
2816
class Pass;
2917
class PassManagerBuilder;
3018

llvm/lib/Transforms/Coroutines/CoroInternal.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,19 @@ void initializeCoroSplitLegacyPass(PassRegistry &);
2626
void initializeCoroElideLegacyPass(PassRegistry &);
2727
void initializeCoroCleanupLegacyPass(PassRegistry &);
2828

29+
// CoroEarly pass marks every function that has coro.begin with a string
30+
// attribute "coroutine.presplit"="0". CoroSplit pass processes the coroutine
31+
// twice. First, it lets it go through complete IPO optimization pipeline as a
32+
// single function. It forces restart of the pipeline by inserting an indirect
33+
// call to an empty function "coro.devirt.trigger" which is devirtualized by
34+
// CoroElide pass that triggers a restart of the pipeline by CGPassManager.
35+
// When CoroSplit pass sees the same coroutine the second time, it splits it up,
36+
// adds coroutine subfunctions to the SCC to be processed by IPO pipeline.
37+
38+
#define CORO_PRESPLIT_ATTR "coroutine.presplit"
39+
#define UNPREPARED_FOR_SPLIT "0"
40+
#define PREPARED_FOR_SPLIT "1"
41+
2942
#define CORO_DEVIRT_TRIGGER_FN "coro.devirt.trigger"
3043

3144
namespace coro {

llvm/lib/Transforms/IPO/AlwaysInliner.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "llvm/IR/Module.h"
2323
#include "llvm/IR/Type.h"
2424
#include "llvm/InitializePasses.h"
25-
#include "llvm/Transforms/Coroutines.h"
2625
#include "llvm/Transforms/IPO.h"
2726
#include "llvm/Transforms/IPO/Inliner.h"
2827
#include "llvm/Transforms/Utils/Cloning.h"
@@ -45,14 +44,7 @@ PreservedAnalyses AlwaysInlinerPass::run(Module &M,
4544
SmallSetVector<CallBase *, 16> Calls;
4645
bool Changed = false;
4746
SmallVector<Function *, 16> InlinedFunctions;
48-
for (Function &F : M) {
49-
// When callee coroutine function is inlined into caller coroutine function
50-
// before coro-split pass,
51-
// coro-early pass can not handle this quiet well.
52-
// So we won't inline the coroutine function if it have not been unsplited
53-
if (F.hasFnAttribute(CORO_PRESPLIT_ATTR))
54-
continue;
55-
47+
for (Function &F : M)
5648
if (!F.isDeclaration() && F.hasFnAttribute(Attribute::AlwaysInline) &&
5749
isInlineViable(F).isSuccess()) {
5850
Calls.clear();
@@ -74,7 +66,6 @@ PreservedAnalyses AlwaysInlinerPass::run(Module &M,
7466
// invalidation issues while deleting functions.
7567
InlinedFunctions.push_back(&F);
7668
}
77-
}
7869

7970
// Remove any live functions.
8071
erase_if(InlinedFunctions, [&](Function *F) {
@@ -167,13 +158,6 @@ InlineCost AlwaysInlinerLegacyPass::getInlineCost(CallBase &CB) {
167158
if (!Callee)
168159
return InlineCost::getNever("indirect call");
169160

170-
// When callee coroutine function is inlined into caller coroutine function
171-
// before coro-split pass,
172-
// coro-early pass can not handle this quiet well.
173-
// So we won't inline the coroutine function if it have not been unsplited
174-
if (Callee->hasFnAttribute(CORO_PRESPLIT_ATTR))
175-
return InlineCost::getNever("unsplited coroutine call");
176-
177161
// FIXME: We shouldn't even get here for declarations.
178162
if (Callee->isDeclaration())
179163
return InlineCost::getNever("no definition");

llvm/lib/Transforms/IPO/SampleProfile.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
#include "llvm/Support/ErrorOr.h"
7676
#include "llvm/Support/GenericDomTree.h"
7777
#include "llvm/Support/raw_ostream.h"
78-
#include "llvm/Transforms/Coroutines.h"
7978
#include "llvm/Transforms/IPO.h"
8079
#include "llvm/Transforms/Instrumentation.h"
8180
#include "llvm/Transforms/Utils/CallPromotionUtils.h"
@@ -921,14 +920,6 @@ bool SampleProfileLoader::inlineCallInstruction(CallBase &CB) {
921920

922921
Function *CalledFunction = CB.getCalledFunction();
923922
assert(CalledFunction);
924-
925-
// When callee coroutine function is inlined into caller coroutine function
926-
// before coro-split pass,
927-
// coro-early pass can not handle this quiet well.
928-
// So we won't inline the coroutine function if it have not been unsplited
929-
if (CalledFunction->hasFnAttribute(CORO_PRESPLIT_ATTR))
930-
return false;
931-
932923
DebugLoc DLoc = CB.getDebugLoc();
933924
BasicBlock *BB = CB.getParent();
934925
InlineParams Params = getInlineParams();

llvm/test/Transforms/Coroutines/Inputs/sample.text.prof

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

llvm/test/Transforms/Coroutines/coro-inline.ll

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

0 commit comments

Comments
 (0)