[PATCH] D148788: [NFC] Return unique dbg intrinsics from findDbgValues and findDbgUsers

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 20 04:18:03 PDT 2023


jmorse accepted this revision.
jmorse added a comment.
This revision is now accepted and ready to land.

LGTM with a request for de-duplication, do fold that in when committing.

I'd prefer to not delete assertions if we can possibly avoid it, on the other hand there might be better ways for us to approach every-API-user-being-correct that's less disruptive. We should switch to that approach if this continues to fire (it's clearly rare enough that it's not going to break everyone's debug experience).



================
Comment at: llvm/lib/IR/DebugInfo.cpp:107-121
   SmallPtrSet<DbgVariableIntrinsic *, 4> EncounteredDbgValues;
   if (auto *L = LocalAsMetadata::getIfExists(V)) {
     if (auto *MDV = MetadataAsValue::getIfExists(V->getContext(), L)) {
       for (User *U : MDV->users())
         if (DbgVariableIntrinsic *DII = dyn_cast<DbgVariableIntrinsic>(U))
-          DbgUsers.push_back(DII);
+          if (EncounteredDbgValues.insert(DII).second)
+            DbgUsers.push_back(DII);
----------------
Now that the body of the loops is identical between DIArgLists and LocalAsMetadatas, could you refactor this into a lambda/delegate to reduce duplication.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148788/new/

https://reviews.llvm.org/D148788



More information about the llvm-commits mailing list