summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Coroutines
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Coroutines')
-rw-r--r--llvm/lib/Transforms/Coroutines/CoroFrame.cpp5
-rw-r--r--llvm/lib/Transforms/Coroutines/CoroSplit.cpp14
2 files changed, 13 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index f6e0499a501..2b4e725fd0e 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -27,6 +27,7 @@
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/circular_raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
+#include "llvm/Transforms/Utils/Local.h"
using namespace llvm;
@@ -637,6 +638,10 @@ static void splitAround(Instruction *I, const Twine &Name) {
}
void coro::buildCoroutineFrame(Function &F, Shape &Shape) {
+ // Lower coro.dbg.declare to coro.dbg.value, since we are going to rewrite
+ // access to local variables.
+ LowerDbgDeclare(F);
+
Shape.PromiseAlloca = Shape.CoroBegin->getId()->getPromise();
if (Shape.PromiseAlloca) {
Shape.CoroBegin->getId()->clearPromise();
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index 7233e5301b1..77c4be88a4e 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -200,14 +200,16 @@ static Function *createClone(Function &F, Twine Suffix, coro::Shape &Shape,
SmallVector<ReturnInst *, 4> Returns;
+ if (DISubprogram *SP = F.getSubprogram()) {
+ // If we have debug info, add mapping for the metadata nodes that should not
+ // be cloned by CloneFunctionInfo.
+ auto &MD = VMap.MD();
+ MD[SP->getUnit()].reset(SP->getUnit());
+ MD[SP->getType()].reset(SP->getType());
+ MD[SP->getFile()].reset(SP->getFile());
+ }
CloneFunctionInto(NewF, &F, VMap, /*ModuleLevelChanges=*/true, Returns);
- // If we have debug info, update it. ModuleLevelChanges = true above, does
- // the heavy lifting, we just need to repoint subprogram at the same
- // DICompileUnit as the original function F.
- if (DISubprogram *SP = F.getSubprogram())
- NewF->getSubprogram()->replaceUnit(SP->getUnit());
-
// Remove old returns.
for (ReturnInst *Return : Returns)
changeToUnreachable(Return, /*UseLLVMTrap=*/false);
OpenPOWER on IntegriCloud