Skip to content

Commit 1f0d8b5

Browse files
inline new call to caller
1 parent f34c753 commit 1f0d8b5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

llvm/lib/Transforms/Coroutines/CoroAnnotationElide.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "llvm/IR/Module.h"
2727
#include "llvm/IR/PassManager.h"
2828
#include "llvm/Transforms/Utils/CallGraphUpdater.h"
29+
#include "llvm/Transforms/Utils/Cloning.h"
2930

3031
#include <cassert>
3132

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

9495
NewCB->removeFnAttr(llvm::Attribute::CoroElideSafe);
9596
CB->replaceAllUsesWith(NewCB);
96-
CB->eraseFromParent();
97+
98+
InlineFunctionInfo IFI;
99+
InlineResult IR = InlineFunction(*NewCB, IFI);
100+
if (IR.isSuccess()) {
101+
CB->eraseFromParent();
102+
} else {
103+
NewCB->replaceAllUsesWith(CB);
104+
NewCB->eraseFromParent();
105+
}
97106
}
98107

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

0 commit comments

Comments
 (0)