aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorOCHyams <orlando.hyams@sony.com>2023-12-12 14:46:01 +0000
committerOCHyams <orlando.hyams@sony.com>2023-12-12 14:50:07 +0000
commit5457fab15cd210cd7d89278bea173dc5d0261d3b (patch)
treebe9d6e0ef28cd18d5bb3cab38ed9ecee398bf8f7 /llvm/lib/IR
parentc8655fce45af6f2c13285f218bba83d39c84d5a4 (diff)
downloadllvm-5457fab15cd210cd7d89278bea173dc5d0261d3b.zip
llvm-5457fab15cd210cd7d89278bea173dc5d0261d3b.tar.gz
llvm-5457fab15cd210cd7d89278bea173dc5d0261d3b.tar.bz2
Reapply "[RemoveDIs][NFC] Find DPValues using findDbgDeclares (#73500)"
This patch doesn't change any call sites. Depends on #73498. Reverted in 87c686700f68ce24191f027082ef5fb9a654e9d8.
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/DebugInfo.cpp42
-rw-r--r--llvm/lib/IR/DebugProgramInstruction.cpp4
2 files changed, 20 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) {
diff --git a/llvm/lib/IR/DebugProgramInstruction.cpp b/llvm/lib/IR/DebugProgramInstruction.cpp
index df45c6e..7b709a2 100644
--- a/llvm/lib/IR/DebugProgramInstruction.cpp
+++ b/llvm/lib/IR/DebugProgramInstruction.cpp
@@ -203,6 +203,10 @@ DPValue::createDebugIntrinsic(Module *M, Instruction *InsertBefore) const {
case DPValue::LocationType::Value:
IntrinsicFn = Intrinsic::getDeclaration(M, Intrinsic::dbg_value);
break;
+ case DPValue::LocationType::End:
+ case DPValue::LocationType::Any:
+ llvm_unreachable("Invalid LocationType");
+ break;
}
// Create the intrinsic from this DPValue's information, optionally insert