Skip to content

[debug-info] If one sees a spill with a dbg.addr use, salvageDebugInfo upon it and don't hoist it. #3936

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions llvm/lib/Transforms/Coroutines/CoroFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "llvm/IR/Dominators.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.h"
Expand Down Expand Up @@ -1667,6 +1668,12 @@ static Instruction *insertSpills(const FrameDataInfo &FrameData,
}
}

// Salvage debug info on any dbg.addr that we see. We do not insert them
// into each block where we have a use though.
if (auto *DI = dyn_cast<DbgAddrIntrinsic>(U)) {
coro::salvageDebugInfo(DbgPtrAllocaCache, DI, Shape.ReuseFrameSlot);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReuseFrameSlot is the variable that was renamed upstream.

}

// If we have a single edge PHINode, remove it and replace it with a
// reload from the coroutine frame. (We already took care of multi edge
// PHINodes by rewriting them in the rewritePHIs function).
Expand Down Expand Up @@ -2599,8 +2606,11 @@ void coro::salvageDebugInfo(
}
DVI->replaceVariableLocationOp(OriginalStorage, Storage);
DVI->setExpression(Expr);
/// It makes no sense to move the dbg.value intrinsic.
if (!isa<DbgValueInst>(DVI)) {

// We only hoist dbg.declare today since it doesn't make sense to hoist
// dbg.value or dbg.addr since they do not have the same function wide
// guarantees that dbg.declare does.
if (!isa<DbgValueInst>(DVI) && !isa<DbgAddrIntrinsic>(DVI)) {
if (auto *InsertPt = dyn_cast<Instruction>(Storage))
DVI->moveAfter(InsertPt);
else if (isa<Argument>(Storage))
Expand Down
Loading