Skip to content

Commit 19279ff

Browse files
committed
[debug-info] If one sees a spill with a dbg.addr use, salvageDebugInfo upon it and don't hoist it.
This ensures that if we have a dbg.addr in a coroutine funclet that is on one of our function arguments, that the dbg.addr is not mapped to undef and also that later it isn't hoisted to the front of the basic block. Instead it remains at its original cloned location. rdar://83957028 Differential Revision: https://reviews.llvm.org/D119576
1 parent 0574b5f commit 19279ff

File tree

3 files changed

+710
-2
lines changed

3 files changed

+710
-2
lines changed

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "llvm/IR/Dominators.h"
2828
#include "llvm/IR/IRBuilder.h"
2929
#include "llvm/IR/InstIterator.h"
30+
#include "llvm/IR/IntrinsicInst.h"
3031
#include "llvm/Support/CommandLine.h"
3132
#include "llvm/Support/Debug.h"
3233
#include "llvm/Support/MathExtras.h"
@@ -1662,6 +1663,12 @@ static Instruction *insertSpills(const FrameDataInfo &FrameData,
16621663
}
16631664
}
16641665

1666+
// Salvage debug info on any dbg.addr that we see. We do not insert them
1667+
// into each block where we have a use though.
1668+
if (auto *DI = dyn_cast<DbgAddrIntrinsic>(U)) {
1669+
coro::salvageDebugInfo(DbgPtrAllocaCache, DI, Shape.OptimizeFrame);
1670+
}
1671+
16651672
// If we have a single edge PHINode, remove it and replace it with a
16661673
// reload from the coroutine frame. (We already took care of multi edge
16671674
// PHINodes by rewriting them in the rewritePHIs function).
@@ -2579,8 +2586,10 @@ void coro::salvageDebugInfo(
25792586

25802587
DVI->replaceVariableLocationOp(OriginalStorage, Storage);
25812588
DVI->setExpression(Expr);
2582-
/// It makes no sense to move the dbg.value intrinsic.
2583-
if (!isa<DbgValueInst>(DVI)) {
2589+
// We only hoist dbg.declare today since it doesn't make sense to hoist
2590+
// dbg.value or dbg.addr since they do not have the same function wide
2591+
// guarantees that dbg.declare does.
2592+
if (!isa<DbgValueInst>(DVI) && !isa<DbgAddrIntrinsic>(DVI)) {
25842593
if (auto *II = dyn_cast<InvokeInst>(Storage))
25852594
DVI->moveBefore(II->getNormalDest()->getFirstNonPHI());
25862595
else if (auto *CBI = dyn_cast<CallBrInst>(Storage))

0 commit comments

Comments
 (0)