diff options
author | Stephen Tozer <stephen.tozer@sony.com> | 2024-02-29 14:37:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-29 14:37:06 +0000 |
commit | aadd7650447b301f8d08fe94a886df05971adecb (patch) | |
tree | 46dc80d1c4aa7832614654ca97b9edbedb7566d2 /llvm/lib/IR/DebugInfo.cpp | |
parent | ec95379df363253ffcbbda21297417e703d5ccca (diff) | |
download | llvm-aadd7650447b301f8d08fe94a886df05971adecb.zip llvm-aadd7650447b301f8d08fe94a886df05971adecb.tar.gz llvm-aadd7650447b301f8d08fe94a886df05971adecb.tar.bz2 |
[DebugInfo][RemoveDIs] Prevent duplicate DPValues from being returned by findDbgIntrinsics (#82764)
Fixes the error described here:
https://github.com/llvm/llvm-project/commit/a93a4ec7dd205b965ee5597314bb376520cd736c#commitcomment-138965199
The function `findDbgIntrinsics` is used to return a list of debug
intrinsics and DPValues that use a given value, with the intent that no
duplicates are returned in either list. For DPValues, we've guarded
against DPValues that use a value multiple times as part of a DIArgList,
but we have not guarded against DPValues that use a value multiple times
as separate operands (currently only possible for `dbg_assign`s,
something I missed in my implementation of that type!). This patch adds
a guard, and also updates a test to cover this case.
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index e044ab3..1f3ff22 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -99,8 +99,8 @@ static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V, SmallPtrSet<DPValue *, 4> EncounteredDPValues; /// Append IntrinsicT users of MetadataAsValue(MD). - auto AppendUsers = [&Ctx, &EncounteredIntrinsics, &Result, - DPValues](Metadata *MD) { + auto AppendUsers = [&Ctx, &EncounteredIntrinsics, &EncounteredDPValues, + &Result, DPValues](Metadata *MD) { if (auto *MDV = MetadataAsValue::getIfExists(Ctx, MD)) { for (User *U : MDV->users()) if (IntrinsicT *DVI = dyn_cast<IntrinsicT>(U)) @@ -113,7 +113,8 @@ static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V, if (LocalAsMetadata *L = dyn_cast<LocalAsMetadata>(MD)) { for (DPValue *DPV : L->getAllDPValueUsers()) { if (Type == DPValue::LocationType::Any || DPV->getType() == Type) - DPValues->push_back(DPV); + if (EncounteredDPValues.insert(DPV).second) + DPValues->push_back(DPV); } } }; |