Skip to content

Commit ebe9411

Browse files
authored
Merge pull request #3936 from gottesmm/stable/20211026/coro-dbg.addr
[debug-info] If one sees a spill with a dbg.addr use, salvageDebugInfo upon it and don't hoist it.
2 parents 15f059d + 6bd73c1 commit ebe9411

File tree

3 files changed

+711
-2
lines changed

3 files changed

+711
-2
lines changed

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "llvm/IR/Dominators.h"
2626
#include "llvm/IR/IRBuilder.h"
2727
#include "llvm/IR/InstIterator.h"
28+
#include "llvm/IR/IntrinsicInst.h"
2829
#include "llvm/Support/CommandLine.h"
2930
#include "llvm/Support/Debug.h"
3031
#include "llvm/Support/MathExtras.h"
@@ -1667,6 +1668,12 @@ static Instruction *insertSpills(const FrameDataInfo &FrameData,
16671668
}
16681669
}
16691670

1671+
// Salvage debug info on any dbg.addr that we see. We do not insert them
1672+
// into each block where we have a use though.
1673+
if (auto *DI = dyn_cast<DbgAddrIntrinsic>(U)) {
1674+
coro::salvageDebugInfo(DbgPtrAllocaCache, DI, Shape.ReuseFrameSlot);
1675+
}
1676+
16701677
// If we have a single edge PHINode, remove it and replace it with a
16711678
// reload from the coroutine frame. (We already took care of multi edge
16721679
// PHINodes by rewriting them in the rewritePHIs function).
@@ -2599,8 +2606,11 @@ void coro::salvageDebugInfo(
25992606
}
26002607
DVI->replaceVariableLocationOp(OriginalStorage, Storage);
26012608
DVI->setExpression(Expr);
2602-
/// It makes no sense to move the dbg.value intrinsic.
2603-
if (!isa<DbgValueInst>(DVI)) {
2609+
2610+
// We only hoist dbg.declare today since it doesn't make sense to hoist
2611+
// dbg.value or dbg.addr since they do not have the same function wide
2612+
// guarantees that dbg.declare does.
2613+
if (!isa<DbgValueInst>(DVI) && !isa<DbgAddrIntrinsic>(DVI)) {
26042614
if (auto *InsertPt = dyn_cast<Instruction>(Storage))
26052615
DVI->moveAfter(InsertPt);
26062616
else if (isa<Argument>(Storage))

0 commit comments

Comments
 (0)