aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
authorOrlando Cazalet-Hyams <orlando.hyams@sony.com>2024-04-30 08:48:24 +0100
committerGitHub <noreply@github.com>2024-04-30 08:48:24 +0100
commit09e7d86b99c6e6d4f4a3296647d1b7d803c5bac5 (patch)
treef5c8c1b8820988ace88bf2d28802d7c19237bede /llvm/lib/IR/DebugInfo.cpp
parent91a8cb781dbc981356207e0c3608d92ed6d26042 (diff)
downloadllvm-09e7d86b99c6e6d4f4a3296647d1b7d803c5bac5.zip
llvm-09e7d86b99c6e6d4f4a3296647d1b7d803c5bac5.tar.gz
llvm-09e7d86b99c6e6d4f4a3296647d1b7d803c5bac5.tar.bz2
[RemoveDIs] Fix findDbgValues to return dbg_assign records too (#90471)
In the debug intrinsic class heirachy, a dbg.assign is a (inherits from) dbg.value, so `findDbgValues` returns dbg.values and dbg.assigns (by design). That hierarchy doesn't exist for DbgRecords - fix findDbgValues to return dbg_assign records as well as dbg_values and add unittest.
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r--llvm/lib/IR/DebugInfo.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 4206162..7976904 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -80,8 +80,7 @@ TinyPtrVector<DbgVariableRecord *> llvm::findDVRDeclares(Value *V) {
return Declares;
}
-template <typename IntrinsicT, DbgVariableRecord::LocationType Type =
- DbgVariableRecord::LocationType::Any>
+template <typename IntrinsicT, bool DbgAssignAndValuesOnly>
static void
findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords) {
@@ -114,8 +113,7 @@ findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
// Get DbgVariableRecords that use this as a single value.
if (LocalAsMetadata *L = dyn_cast<LocalAsMetadata>(MD)) {
for (DbgVariableRecord *DVR : L->getAllDbgVariableRecordUsers()) {
- if (Type == DbgVariableRecord::LocationType::Any ||
- DVR->getType() == Type)
+ if (!DbgAssignAndValuesOnly || DVR->isDbgValue() || DVR->isDbgAssign())
if (EncounteredDbgVariableRecords.insert(DVR).second)
DbgVariableRecords->push_back(DVR);
}
@@ -130,8 +128,7 @@ findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
continue;
DIArgList *DI = cast<DIArgList>(AL);
for (DbgVariableRecord *DVR : DI->getAllDbgVariableRecordUsers())
- if (Type == DbgVariableRecord::LocationType::Any ||
- DVR->getType() == Type)
+ if (!DbgAssignAndValuesOnly || DVR->isDbgValue() || DVR->isDbgAssign())
if (EncounteredDbgVariableRecords.insert(DVR).second)
DbgVariableRecords->push_back(DVR);
}
@@ -141,14 +138,14 @@ findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
void llvm::findDbgValues(
SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V,
SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords) {
- findDbgIntrinsics<DbgValueInst, DbgVariableRecord::LocationType::Value>(
+ findDbgIntrinsics<DbgValueInst, /*DbgAssignAndValuesOnly=*/true>(
DbgValues, V, DbgVariableRecords);
}
void llvm::findDbgUsers(
SmallVectorImpl<DbgVariableIntrinsic *> &DbgUsers, Value *V,
SmallVectorImpl<DbgVariableRecord *> *DbgVariableRecords) {
- findDbgIntrinsics<DbgVariableIntrinsic, DbgVariableRecord::LocationType::Any>(
+ findDbgIntrinsics<DbgVariableIntrinsic, /*DbgAssignAndValuesOnly=*/false>(
DbgUsers, V, DbgVariableRecords);
}