diff options
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
| -rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 0f9d064857dc..1859bc468cac 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -62,6 +62,23 @@ TinyPtrVector<DbgVariableRecord *> llvm::findDVRDeclares(Value *V) { return Declares; } +TinyPtrVector<DbgVariableRecord *> llvm::findDVRDeclareValues(Value *V) { + // This function is hot. Check whether the value has any metadata to avoid a + // DenseMap lookup. This check is a bitfield datamember lookup. + if (!V->isUsedByMetadata()) + return {}; + auto *L = ValueAsMetadata::getIfExists(V); + if (!L) + return {}; + + TinyPtrVector<DbgVariableRecord *> DEclareValues; + for (DbgVariableRecord *DVR : L->getAllDbgVariableRecordUsers()) + if (DVR->getType() == DbgVariableRecord::LocationType::DeclareValue) + DEclareValues.push_back(DVR); + + return DEclareValues; +} + TinyPtrVector<DbgVariableRecord *> llvm::findDVRValues(Value *V) { // This function is hot. Check whether the value has any metadata to avoid a // DenseMap lookup. This check is a bitfield datamember lookup. |
