aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/DebugInfo.cpp
diff options
context:
space:
mode:
authorOCHyams <orlando.hyams@sony.com>2023-12-12 14:41:01 +0000
committerOCHyams <orlando.hyams@sony.com>2023-12-12 14:41:01 +0000
commit87c686700f68ce24191f027082ef5fb9a654e9d8 (patch)
treee438205579c95690fbe3a4b620c728d3813c487e /llvm/lib/IR/DebugInfo.cpp
parentcd138fddf1b52a43108376371ad1c38585aaa4e2 (diff)
downloadllvm-87c686700f68ce24191f027082ef5fb9a654e9d8.zip
llvm-87c686700f68ce24191f027082ef5fb9a654e9d8.tar.gz
llvm-87c686700f68ce24191f027082ef5fb9a654e9d8.tar.bz2
Revert "[RemoveDIs][NFC] Find DPValues using findDbgDeclares (#73500)"
This reverts commit 17b8f87f76365e65350ec3f7f982b21b8d895598. Buildbot: https://lab.llvm.org/buildbot/#/builders/77/builds/32927
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r--llvm/lib/IR/DebugInfo.cpp42
1 files changed, 26 insertions, 16 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index eab05ee..b3cc999 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -44,10 +44,28 @@ using namespace llvm;
using namespace llvm::at;
using namespace llvm::dwarf;
-template <typename IntrinsicT,
- DPValue::LocationType Type = DPValue::LocationType::Any>
-static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
- SmallVectorImpl<DPValue *> *DPValues) {
+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) {
// This function is hot. Check whether the value has any metadata to avoid a
// DenseMap lookup.
if (!V->isUsedByMetadata())
@@ -76,7 +94,7 @@ static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
// Get DPValues that use this as a single value.
if (LocalAsMetadata *L = dyn_cast<LocalAsMetadata>(MD)) {
for (DPValue *DPV : L->getAllDPValueUsers()) {
- if (Type == DPValue::LocationType::Any || DPV->getType() == Type)
+ if (DPV->getType() == DPValue::LocationType::Value)
DPValues->push_back(DPV);
}
}
@@ -90,29 +108,21 @@ static void findDbgIntrinsics(SmallVectorImpl<IntrinsicT *> &Result, Value *V,
continue;
DIArgList *DI = cast<DIArgList>(AL);
for (DPValue *DPV : DI->getAllDPValueUsers())
- if (Type == DPValue::LocationType::Any || DPV->getType() == Type)
+ if (DPV->getType() == DPValue::LocationType::Value)
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, DPValue::LocationType::Value>(DbgValues, V,
- DPValues);
+ findDbgIntrinsics<DbgValueInst>(DbgValues, V, DPValues);
}
void llvm::findDbgUsers(SmallVectorImpl<DbgVariableIntrinsic *> &DbgUsers,
Value *V, SmallVectorImpl<DPValue *> *DPValues) {
- findDbgIntrinsics<DbgVariableIntrinsic, DPValue::LocationType::Any>(
- DbgUsers, V, DPValues);
+ findDbgIntrinsics<DbgVariableIntrinsic>(DbgUsers, V, DPValues);
}
DISubprogram *llvm::getDISubprogram(const MDNode *Scope) {