[llvm] [DebugInfo][RemoveDIs] Support finding DPValues as well as dbg.values in findDbgValues (PR #71952)
Orlando Cazalet-Hyams via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 16 02:37:45 PST 2023
================
@@ -78,31 +80,53 @@ static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V) {
// V will also appear twice in a dbg.assign if its used in the both the value
// and address components.
SmallPtrSet<IntrinsicT *, 4> EncounteredIntrinsics;
+ SmallPtrSet<DPValue *, 4> EncounteredDPValues;
/// Append IntrinsicT users of MetadataAsValue(MD).
- auto AppendUsers = [&Ctx, &EncounteredIntrinsics, &Result](Metadata *MD) {
+ auto AppendUsers = [&Ctx, &EncounteredIntrinsics, &Result,
+ DPValues](Metadata *MD) {
if (auto *MDV = MetadataAsValue::getIfExists(Ctx, MD)) {
for (User *U : MDV->users())
if (IntrinsicT *DVI = dyn_cast<IntrinsicT>(U))
if (EncounteredIntrinsics.insert(DVI).second)
Result.push_back(DVI);
}
+ if (!DPValues)
+ return;
+ // Get DPValues that use this as a single value.
+ if (LocalAsMetadata *L = dyn_cast<LocalAsMetadata>(MD)) {
+ for (DPValue *DPV : L->getAllDPValueUsers()) {
+ if (DPV->getType() == DPValue::LocationType::Value)
+ DPValues->push_back(DPV);
+ }
+ }
};
if (auto *L = LocalAsMetadata::getIfExists(V)) {
AppendUsers(L);
- for (Metadata *AL : L->getAllArgListUsers())
+ for (Metadata *AL : L->getAllArgListUsers()) {
AppendUsers(AL);
+ if (!DPValues)
+ continue;
+ DIArgList *DI = cast<DIArgList>(AL);
+ if (auto *Replaceable = DI->getReplaceableUses()) {
+ for (DPValue *DPV : Replaceable->getAllDPValueUsers())
+ if (DPV->getType() == DPValue::LocationType::Value)
----------------
OCHyams wrote:
There's a template parameter for intrinsic type but not for DPValue type. What do you think of changing the signature to:
```
template <typename IntrinsicT, bool AnyDPVType, DPValue::LocationType SpecificDPVType = DPValue::LocationType(-1)>
static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result,
Value *V, SmallVectorImpl<DPValue *> *DPValues)
```
Filter DPValeus by `SpecificDPVType` unless `AnyDPVType == true`.
wdyt?
https://github.com/llvm/llvm-project/pull/71952
More information about the llvm-commits
mailing list