[PATCH] D42940: Fix a crash when emitting DIEs for variable-length arrays

Adrian Prantl via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 6 10:10:30 PST 2018


aprantl added inline comments.


================
Comment at: lib/CodeGen/AsmPrinter/DwarfFile.h:52
+  struct ScopeVars {
+    std::map<unsigned, DbgVariable *> Args;
+    SmallVector<DbgVariable *, 8> Locals;
----------------
davide wrote:
> Do you really need `std::map<>` here? Can't you use an LLVM container?
Is there a better container for this? I need something that allows me to
1. check whether an element already exists while building the list
2. traverse all elements in order at the end.

DenseMap doesn't support (2), so the only other alternative I could come up with was a SmallVector or a std::list that is kept sorted after each insert by using std::lower_bound to look up the insertion point. Using a std::list instead the SmallVector would be more memory efficient than the std::map. Using a SmallVector would use least memory, but has quadratic worst-case behavior. Any preferences/suggestions?


https://reviews.llvm.org/D42940





More information about the llvm-commits mailing list