diff options
author | Orlando Cazalet-Hyams <orlando.hyams@sony.com> | 2023-12-12 13:30:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-12 13:30:15 +0000 |
commit | 17b8f87f76365e65350ec3f7f982b21b8d895598 (patch) | |
tree | 1c0839bb408ea1517bc4064e180a78ccb730d089 /llvm/lib/IR/DebugInfo.cpp | |
parent | bfebadc8c392fc3bc8cbd54af735a006f50a5d8c (diff) | |
download | llvm-17b8f87f76365e65350ec3f7f982b21b8d895598.zip llvm-17b8f87f76365e65350ec3f7f982b21b8d895598.tar.gz llvm-17b8f87f76365e65350ec3f7f982b21b8d895598.tar.bz2 |
[RemoveDIs][NFC] Find DPValues using findDbgDeclares (#73500)
This patch doesn't change any call sites.
Depends on #73498.
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index b3cc999..eab05ee 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -44,28 +44,10 @@ using namespace llvm; using namespace llvm::at; using namespace llvm::dwarf; -void llvm::findDbgDeclares(SmallVectorImpl<DbgDeclareInst *> &DbgUsers, - Value *V) { - // This function is hot. Check whether the value has any metadata to avoid a - // DenseMap lookup. - if (!V->isUsedByMetadata()) - return; - auto *L = LocalAsMetadata::getIfExists(V); - if (!L) - return; - auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L); - if (!MDV) - return; - - for (User *U : MDV->users()) { - if (auto *DDI = dyn_cast<DbgDeclareInst>(U)) - DbgUsers.push_back(DDI); - } -} - -template <typename IntrinsicT> -static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, - Value *V, SmallVectorImpl<DPValue *> *DPValues) { +template <typename IntrinsicT, + DPValue::LocationType Type = DPValue::LocationType::Any> +static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V, + SmallVectorImpl<DPValue *> *DPValues) { // This function is hot. Check whether the value has any metadata to avoid a // DenseMap lookup. if (!V->isUsedByMetadata()) @@ -94,7 +76,7 @@ static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, // 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) + if (Type == DPValue::LocationType::Any || DPV->getType() == Type) DPValues->push_back(DPV); } } @@ -108,21 +90,29 @@ static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, continue; DIArgList *DI = cast<DIArgList>(AL); for (DPValue *DPV : DI->getAllDPValueUsers()) - if (DPV->getType() == DPValue::LocationType::Value) + if (Type == DPValue::LocationType::Any || DPV->getType() == Type) if (EncounteredDPValues.insert(DPV).second) DPValues->push_back(DPV); } } } +void llvm::findDbgDeclares(SmallVectorImpl<DbgDeclareInst *> &DbgUsers, + Value *V, SmallVectorImpl<DPValue *> *DPValues) { + findDbgIntrinsics<DbgDeclareInst, DPValue::LocationType::Declare>(DbgUsers, V, + DPValues); +} + void llvm::findDbgValues(SmallVectorImpl<DbgValueInst *> &DbgValues, Value *V, SmallVectorImpl<DPValue *> *DPValues) { - findDbgIntrinsics<DbgValueInst>(DbgValues, V, DPValues); + findDbgIntrinsics<DbgValueInst, DPValue::LocationType::Value>(DbgValues, V, + DPValues); } void llvm::findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgUsers, Value *V, SmallVectorImpl<DPValue *> *DPValues) { - findDbgIntrinsics<DbgVariableIntrinsic>(DbgUsers, V, DPValues); + findDbgIntrinsics<DbgVariableIntrinsic, DPValue::LocationType::Any>( + DbgUsers, V, DPValues); } DISubprogram *llvm::getDISubprogram(const MDNode *Scope) { |