aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
authorJeremy Morse <jeremy.morse@sony.com>2023-11-26 21:24:29 +0000
committerGitHub <noreply@github.com>2023-11-26 21:24:29 +0000
commitc672ba7dde3a6ec2f6c89fcb207c9a6a8474cedc (patch)
treefcd978aedc24c8eb4b68251ad16cdda0310b5ba2 /llvm/lib/IR/DebugInfo.cpp
parentf4a4e2f85d819f44772b29c12a6cd2b86c14d611 (diff)
downloadllvm-c672ba7dde3a6ec2f6c89fcb207c9a6a8474cedc.zip
llvm-c672ba7dde3a6ec2f6c89fcb207c9a6a8474cedc.tar.gz
llvm-c672ba7dde3a6ec2f6c89fcb207c9a6a8474cedc.tar.bz2
[DebugInfo][RemoveDIs] Instrument inliner for non-instr debug-info (#72884)
With intrinsics representing debug-info, we just clone all the intrinsics when inlining a function and don't think about it any further. With non-instruction debug-info however we need to be a bit more careful and manually move the debug-info from one place to another. For the most part, this means keeping a "cursor" during block cloning of where we last copied debug-info from, and performing debug-info copying whenever we successfully clone another instruction. There are several utilities in LLVM for doing this, all of which now need to manually call cloneDebugInfo. The testing story for this is not well covered as we could rely on normal instruction-cloning mechanisms to do all the hard stuff. Thus, I've added a few tests to explicitly test dbg.value behaviours, ahead of them becoming not-instructions.
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r--llvm/lib/IR/DebugInfo.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 95dfc28..3fe940e 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -205,10 +205,13 @@ void DebugInfoFinder::processCompileUnit(DICompileUnit *CU) {
void DebugInfoFinder::processInstruction(const Module &M,
const Instruction &I) {
if (auto *DVI = dyn_cast<DbgVariableIntrinsic>(&I))
- processVariable(M, *DVI);
+ processVariable(M, DVI->getVariable());
if (auto DbgLoc = I.getDebugLoc())
processLocation(M, DbgLoc.get());
+
+ for (const DPValue &DPV : I.getDbgValueRange())
+ processDPValue(M, DPV);
}
void DebugInfoFinder::processLocation(const Module &M, const DILocation *Loc) {
@@ -218,6 +221,11 @@ void DebugInfoFinder::processLocation(const Module &M, const DILocation *Loc) {
processLocation(M, Loc->getInlinedAt());
}
+void DebugInfoFinder::processDPValue(const Module &M, const DPValue &DPV) {
+ processVariable(M, DPV.getVariable());
+ processLocation(M, DPV.getDebugLoc().get());
+}
+
void DebugInfoFinder::processType(DIType *DT) {
if (!addType(DT))
return;
@@ -292,15 +300,7 @@ void DebugInfoFinder::processSubprogram(DISubprogram *SP) {
}
void DebugInfoFinder::processVariable(const Module &M,
- const DbgVariableIntrinsic &DVI) {
- auto *N = dyn_cast<MDNode>(DVI.getVariable());
- if (!N)
- return;
-
- auto *DV = dyn_cast<DILocalVariable>(N);
- if (!DV)
- return;
-
+ const DILocalVariable *DV) {
if (!NodesSeen.insert(DV).second)
return;
processScope(DV->getScope());