[Lldb-commits] [PATCH] D68605: ObjectFileMachO: Replace std::map with llvm::DenseMap (NFC)

2019-10-08 Thread Adrian Prantl via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8db229e28771: ObjectFileMachO: Replace std::map with 
llvm::DenseMap (NFC) (authored by aprantl).
Herald added a project: LLDB.

Changed prior to commit:
  https://reviews.llvm.org/D68605?vs=223685=223894#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68605

Files:
  lldb/include/lldb/Utility/ConstString.h
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -2478,8 +2478,8 @@
   std::vector N_BRAC_indexes;
   std::vector N_COMM_indexes;
   typedef std::multimap ValueToSymbolIndexMap;
-  typedef std::map NListIndexToSymbolIndexMap;
-  typedef std::map ConstNameToSymbolIndexMap;
+  typedef llvm::DenseMap NListIndexToSymbolIndexMap;
+  typedef llvm::DenseMap ConstNameToSymbolIndexMap;
   ValueToSymbolIndexMap N_FUN_addr_to_sym_idx;
   ValueToSymbolIndexMap N_STSYM_addr_to_sym_idx;
   ConstNameToSymbolIndexMap N_GSYM_name_to_sym_idx;
@@ -2689,8 +2689,8 @@
 
 offset = 0;
 
-typedef std::map UndefinedNameToDescMap;
-typedef std::map SymbolIndexToName;
+typedef llvm::DenseMap UndefinedNameToDescMap;
+typedef llvm::DenseMap SymbolIndexToName;
 UndefinedNameToDescMap undefined_name_to_desc;
 SymbolIndexToName reexport_shlib_needs_fixup;
 
@@ -3487,15 +3487,11 @@
   // matches, then we can merge the two into just the
   // function symbol to avoid duplicate entries in
   // the symbol table
-  std::pair
-  range;
-  range =
+  auto range =
   N_FUN_addr_to_sym_idx.equal_range(nlist.n_value);
   if (range.first != range.second) {
 bool found_it = false;
-for (ValueToSymbolIndexMap::const_iterator pos =
- range.first;
+for (const auto pos = range.first;
  pos != range.second; ++pos) {
   if (sym[sym_idx].GetMangled().GetName(
   lldb::eLanguageTypeUnknown,
@@ -3536,15 +3532,11 @@
   // matches, then we can merge the two into just the
   // Static symbol to avoid duplicate entries in the
   // symbol table
-  std::pair
-  range;
-  range = N_STSYM_addr_to_sym_idx.equal_range(
+  auto range = N_STSYM_addr_to_sym_idx.equal_range(
   nlist.n_value);
   if (range.first != range.second) {
 bool found_it = false;
-for (ValueToSymbolIndexMap::const_iterator pos =
- range.first;
+for (const auto pos = range.first;
  pos != range.second; ++pos) {
   if (sym[sym_idx].GetMangled().GetName(
   lldb::eLanguageTypeUnknown,
@@ -3667,8 +3659,8 @@
   nlist_idx = 0;
 }
 
-typedef std::map UndefinedNameToDescMap;
-typedef std::map SymbolIndexToName;
+typedef llvm::DenseMap UndefinedNameToDescMap;
+typedef llvm::DenseMap SymbolIndexToName;
 UndefinedNameToDescMap undefined_name_to_desc;
 SymbolIndexToName reexport_shlib_needs_fixup;
 
Index: lldb/include/lldb/Utility/ConstString.h
===
--- lldb/include/lldb/Utility/ConstString.h
+++ lldb/include/lldb/Utility/ConstString.h
@@ -10,6 +10,7 @@
 #define liblldb_ConstString_h_
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/Support/FormatVariadic.h"
 
 #include 
@@ -437,6 +438,14 @@
   static size_t StaticMemorySize();
 
 protected:
+  template  friend struct ::llvm::DenseMapInfo;
+  /// Only used by DenseMapInfo.
+  static ConstString FromStringPoolPointer(const char *ptr) {
+ConstString s;
+s.m_string = ptr;
+return s;
+  };
+
   // Member variables
   const char *m_string;
 };
@@ -451,6 +460,27 @@
   static void format(const lldb_private::ConstString , llvm::raw_ostream ,
  llvm::StringRef Options);
 };
+
+/// DenseMapInfo implementation.
+/// \{
+template <> 

[Lldb-commits] [PATCH] D68605: ObjectFileMachO: Replace std::map with llvm::DenseMap (NFC)

2019-10-08 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl abandoned this revision.
aprantl added a comment.

Pavel correctly pointed out that this isn't necessarily correct, because the 
addresses could conflict with the Tombstone/Empty keys.


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

https://reviews.llvm.org/D68605



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68605: ObjectFileMachO: Replace std::map with llvm::DenseMap (NFC)

2019-10-08 Thread Pavel Labath via Phabricator via lldb-commits
labath added inline comments.



Comment at: lldb/include/lldb/Utility/ConstString.h:441
 protected:
+  template  friend struct ::llvm::DenseMapInfo;
+  /// Only used by DenseMapInfo.

You could declare the specific instantiation (DenseMapInfo) as a 
friend instead of the whole template.



Comment at: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp:2496
   std::vector trie_entries;
-  std::set resolver_addresses;
+  llvm::DenseSet resolver_addresses;
 

It looks like the values for these are coming straight from the object file 
(aka user input). Are you ok with asserting on "resolvers" like 0xff...ff ?


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

https://reviews.llvm.org/D68605



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68605: ObjectFileMachO: Replace std::map with llvm::DenseMap (NFC)

2019-10-07 Thread Adrian Prantl via Phabricator via lldb-commits
aprantl created this revision.
aprantl added reviewers: JDevlieghere, labath.

This makes parsing the symbol table of clang ~10ms faster. (Hashtable versus 
tree).


https://reviews.llvm.org/D68605

Files:
  lldb/include/lldb/Utility/ConstString.h
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Index: lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
===
--- lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1932,7 +1932,7 @@
 static bool ParseTrieEntries(DataExtractor , lldb::offset_t offset,
  const bool is_arm,
  std::vector ,
- std::set _addresses,
+ llvm::DenseSet _addresses,
  std::vector ) {
   if (!data.ValidOffset(offset))
 return true;
@@ -2475,8 +2475,8 @@
   std::vector N_BRAC_indexes;
   std::vector N_COMM_indexes;
   typedef std::multimap ValueToSymbolIndexMap;
-  typedef std::map NListIndexToSymbolIndexMap;
-  typedef std::map ConstNameToSymbolIndexMap;
+  typedef llvm::DenseMap NListIndexToSymbolIndexMap;
+  typedef llvm::DenseMap ConstNameToSymbolIndexMap;
   ValueToSymbolIndexMap N_FUN_addr_to_sym_idx;
   ValueToSymbolIndexMap N_STSYM_addr_to_sym_idx;
   ConstNameToSymbolIndexMap N_GSYM_name_to_sym_idx;
@@ -2493,7 +2493,7 @@
   uint32_t unmapped_local_symbols_found = 0;
 
   std::vector trie_entries;
-  std::set resolver_addresses;
+  llvm::DenseSet resolver_addresses;
 
   if (dyld_trie_data.GetByteSize() > 0) {
 std::vector nameSlices;
@@ -2686,8 +2686,8 @@
 
 offset = 0;
 
-typedef std::map UndefinedNameToDescMap;
-typedef std::map SymbolIndexToName;
+typedef llvm::DenseMap UndefinedNameToDescMap;
+typedef llvm::DenseMap SymbolIndexToName;
 UndefinedNameToDescMap undefined_name_to_desc;
 SymbolIndexToName reexport_shlib_needs_fixup;
 
@@ -3484,15 +3484,11 @@
   // matches, then we can merge the two into just the
   // function symbol to avoid duplicate entries in
   // the symbol table
-  std::pair
-  range;
-  range =
+  auto range =
   N_FUN_addr_to_sym_idx.equal_range(nlist.n_value);
   if (range.first != range.second) {
 bool found_it = false;
-for (ValueToSymbolIndexMap::const_iterator pos =
- range.first;
+for (const auto pos = range.first;
  pos != range.second; ++pos) {
   if (sym[sym_idx].GetMangled().GetName(
   lldb::eLanguageTypeUnknown,
@@ -3533,15 +3529,11 @@
   // matches, then we can merge the two into just the
   // Static symbol to avoid duplicate entries in the
   // symbol table
-  std::pair
-  range;
-  range = N_STSYM_addr_to_sym_idx.equal_range(
+  auto range = N_STSYM_addr_to_sym_idx.equal_range(
   nlist.n_value);
   if (range.first != range.second) {
 bool found_it = false;
-for (ValueToSymbolIndexMap::const_iterator pos =
- range.first;
+for (const auto pos = range.first;
  pos != range.second; ++pos) {
   if (sym[sym_idx].GetMangled().GetName(
   lldb::eLanguageTypeUnknown,
@@ -3664,8 +3656,8 @@
   nlist_idx = 0;
 }
 
-typedef std::map UndefinedNameToDescMap;
-typedef std::map SymbolIndexToName;
+typedef llvm::DenseMap UndefinedNameToDescMap;
+typedef llvm::DenseMap SymbolIndexToName;
 UndefinedNameToDescMap undefined_name_to_desc;
 SymbolIndexToName reexport_shlib_needs_fixup;
 for (; nlist_idx < symtab_load_command.nsyms; ++nlist_idx) {
Index: lldb/include/lldb/Utility/ConstString.h
===
--- lldb/include/lldb/Utility/ConstString.h
+++ lldb/include/lldb/Utility/ConstString.h
@@ -10,6 +10,7 @@
 #define liblldb_ConstString_h_
 
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/Support/FormatVariadic.h"
 
 #include 
@@ -437,6 +438,14 @@
   static size_t StaticMemorySize();
 
 protected:
+  template  friend struct ::llvm::DenseMapInfo;
+  /// Only used by DenseMapInfo.
+  static