This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Filter duplicates in Target::GetScratchTypeSystems
ClosedPublic

Authored by teemperor on Oct 16 2021, 3:13 AM.

Details

Summary

Target::GetScratchTypeSystems returns the list of scratch TypeSystems. The
current implementation is iterating over all LanguageType values and retrieves
the respective TypeSystem for each LanguageType.

All C/C++/Obj-C LanguageTypes are however mapped to the same
ScratchTypeSystemClang instance, so the current implementation adds this
single TypeSystem instance several times to the list of TypeSystems (once
for every LanguageType that we support).

The only observable effect of this is that SBTarget.FindTypes for builtin
types currently queries the ScratchTypeSystemClang several times (and also
adds the same result several times).

Diff Detail

Event Timeline

teemperor created this revision.Oct 16 2021, 3:13 AM
teemperor requested review of this revision.Oct 16 2021, 3:13 AM
labath accepted this revision.Oct 18 2021, 12:33 AM
labath added inline comments.
lldb/source/Target/Target.cpp
2238

This might be a good use case for a "sorted vector" https://llvm.org/docs/ProgrammersManual.html#a-sorted-vector

This revision is now accepted and ready to land.Oct 18 2021, 12:33 AM
teemperor updated this revision to Diff 380386.Oct 18 2021, 7:19 AM
  • Use std::vector -> sort -> unique

Eh wait, that's not correct. We can't sort this as there is no ordering for TypeSystems and if we sort by pointer value then this is all non-deterministic. I'll revert back to the original revision.

teemperor updated this revision to Diff 380388.Oct 18 2021, 7:22 AM
  • Back to SetVector
bulbazord accepted this revision.Oct 18 2021, 11:06 AM

Makes sense to me!

labath accepted this revision.Oct 18 2021, 11:25 PM

Eh wait, that's not correct. We can't sort this as there is no ordering for TypeSystems and if we sort by pointer value then this is all non-deterministic. I'll revert back to the original revision.

Ah, sorry for leading you into a dead end.

Eh wait, that's not correct. We can't sort this as there is no ordering for TypeSystems and if we sort by pointer value then this is all non-deterministic. I'll revert back to the original revision.

Ah, sorry for leading you into a dead end.

No worries, I just noticed it after I updated the review. Just wanted to elaborate why I'm reverting back to the original implementation.