15-20% speed improvement when parsing DWARF. I used instruments to
find the hotspots in our code when indexing the DWARF. A combination of
using SmallVector to avoid collection allocations, using fixed form
sizes when possible, and optimizing the hot loops contributed to the
speedup.

llvm-svn: 113961
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index d388d54..2c89775 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1024,6 +1024,8 @@
 
     size_t count = 0;
     const DWARFDebugInfoEntry *die;
+    const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize());
+
     for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling())
     {
         dw_tag_t tag = die->Tag();
@@ -1033,7 +1035,7 @@
         case DW_TAG_member:
             {
                 DWARFDebugInfoEntry::Attributes attributes;
-                const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes);
+                const size_t num_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes);
                 if (num_attributes > 0)
                 {
                     Declaration decl;
@@ -1124,7 +1126,7 @@
                     default_accessibility = eAccessPrivate;
                 // TODO: implement DW_TAG_inheritance type parsing
                 DWARFDebugInfoEntry::Attributes attributes;
-                const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes);
+                const size_t num_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes);
                 if (num_attributes > 0)
                 {
                     Declaration decl;
@@ -1915,6 +1917,8 @@
     if (parent_die == NULL)
         return 0;
 
+    const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize());
+
     size_t count = 0;
     const DWARFDebugInfoEntry *die;
     for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling())
@@ -1925,7 +1929,7 @@
         case DW_TAG_formal_parameter:
             {
                 DWARFDebugInfoEntry::Attributes attributes;
-                const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes);
+                const size_t num_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes);
                 if (num_attributes > 0)
                 {
                     const char *name = NULL;
@@ -2010,13 +2014,15 @@
 
     size_t enumerators_added = 0;
     const DWARFDebugInfoEntry *die;
+    const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize());
+
     for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling())
     {
         const dw_tag_t tag = die->Tag();
         if (tag == DW_TAG_enumerator)
         {
             DWARFDebugInfoEntry::Attributes attributes;
-            const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, attributes);
+            const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes);
             if (num_child_attributes > 0)
             {
                 const char *name = NULL;
@@ -2081,6 +2087,7 @@
         return;
 
     const DWARFDebugInfoEntry *die;
+    const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (dwarf_cu->GetAddressByteSize());
     for (die = parent_die->GetFirstChild(); die != NULL; die = die->GetSibling())
     {
         const dw_tag_t tag = die->Tag();
@@ -2089,7 +2096,7 @@
         case DW_TAG_enumerator:
             {
                 DWARFDebugInfoEntry::Attributes attributes;
-                const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, attributes);
+                const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes);
                 if (num_child_attributes > 0)
                 {
                     const char *name = NULL;
@@ -2131,7 +2138,7 @@
         case DW_TAG_subrange_type:
             {
                 DWARFDebugInfoEntry::Attributes attributes;
-                const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, attributes);
+                const size_t num_child_attributes = die->GetAttributes(this, dwarf_cu, fixed_form_sizes, attributes);
                 if (num_child_attributes > 0)
                 {
                     const char *name = NULL;
@@ -2354,7 +2361,7 @@
                     // Set a bit that lets us know that we are currently parsing this
                     const_cast<DWARFDebugInfoEntry*>(die)->SetUserData(DIE_IS_BEING_PARSED);
 
-                    const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes);
+                    const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
                     Declaration decl;
                     uint32_t encoding = 0;
                     size_t byte_size = 0;
@@ -2482,7 +2489,7 @@
                     LanguageType class_language = eLanguageTypeUnknown;
                     //bool struct_is_class = false;
                     Declaration decl;
-                    const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes);
+                    const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
                     if (num_attributes > 0)
                     {
                         uint32_t i;
@@ -2637,7 +2644,7 @@
                     lldb::user_id_t encoding_uid = DW_INVALID_OFFSET;
                     Declaration decl;
 
-                    const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes);
+                    const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
                     if (num_attributes > 0)
                     {
                         uint32_t i;
@@ -2712,7 +2719,7 @@
                     clang::FunctionDecl::StorageClass storage = clang::FunctionDecl::None;//, Extern, Static, PrivateExtern
 
 
-                    const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes);
+                    const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
                     if (num_attributes > 0)
                     {
                         uint32_t i;
@@ -2826,7 +2833,7 @@
                     int64_t first_index = 0;
                     uint32_t byte_stride = 0;
                     uint32_t bit_stride = 0;
-                    const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes);
+                    const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
 
                     if (num_attributes > 0)
                     {
@@ -2904,7 +2911,7 @@
                     dw_offset_t type_die_offset = DW_INVALID_OFFSET;
                     dw_offset_t containing_type_die_offset = DW_INVALID_OFFSET;
 
-                    const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes);
+                    const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
                     
                     if (num_attributes > 0) {
                         uint32_t i;
@@ -3173,7 +3180,7 @@
     
     const dw_tag_t tag = die->Tag();
     DWARFDebugInfoEntry::Attributes attributes;
-    const size_t num_attributes = die->GetAttributes(this, dwarf_cu, attributes);
+    const size_t num_attributes = die->GetAttributes(this, dwarf_cu, NULL, attributes);
     if (num_attributes > 0)
     {
         const char *name = NULL;