Skip to content

Commit 00b1d1b

Browse files
inline new call to caller
1 parent 61005bf commit 00b1d1b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

llvm/lib/Transforms/Coroutines/CoroAnnotationElide.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include "llvm/IR/Instruction.h"
2525
#include "llvm/IR/Module.h"
2626
#include "llvm/IR/PassManager.h"
27+
#include "llvm/Transforms/Utils/CallGraphUpdater.h"
28+
#include "llvm/Transforms/Utils/Cloning.h"
2729

2830
#include <cassert>
2931

@@ -91,7 +93,15 @@ static void processCall(CallBase *CB, Function *Caller, Function *NewCallee,
9193

9294
NewCB->removeFnAttr(llvm::Attribute::CoroElideSafe);
9395
CB->replaceAllUsesWith(NewCB);
94-
CB->eraseFromParent();
96+
97+
InlineFunctionInfo IFI;
98+
InlineResult IR = InlineFunction(*NewCB, IFI);
99+
if (IR.isSuccess()) {
100+
CB->eraseFromParent();
101+
} else {
102+
NewCB->replaceAllUsesWith(CB);
103+
NewCB->eraseFromParent();
104+
}
95105
}
96106

97107
PreservedAnalyses CoroAnnotationElidePass::run(LazyCallGraph::SCC &C,

0 commit comments

Comments
 (0)