[llvm] [RemoveDIs][NFC] Find DPValues using findDbgDeclares (PR #73500)

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 11 06:18:15 PST 2023


================
@@ -44,29 +44,12 @@ 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;
+template <typename IntrinsicT, bool AnyType,
+          DPValue::LocationType Type = DPValue::LocationType(-1)>
----------------
jmorse wrote:

https://eel.is/c++draft/expr.static.cast para 10 indicates that this may be undefined behaviour. IMO we should bite the bullet and add an "End" type to the enumeration, followed by an "Any" type that's explicitly to be used in APIs like this. Slightly less than ideal, but at least well formed.
I'd also suggest "AnyKind" rather than "AnyType", to avoid mixing the ideas of C++ types and DPValue stuff.

https://github.com/llvm/llvm-project/pull/73500


More information about the llvm-commits mailing list