Skip to content

Commit a061449

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 (cherry picked from commit 19279ff) Conflicts: llvm/lib/Transforms/Coroutines/CoroFrame.cpp The conflict was that the upstream code here seems to handle more cases. I just did the same transform I did in OSS here (which is not hoisting llvm.dbg.addr). The rest of the code is unchanged.
1 parent ca43d6d commit a061449

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.OptimizeFrame);
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)