diff --git a/gcc/hash-traits.h b/gcc/hash-traits.h index b16975cfeb3..bef0bd42d04 100644 --- a/gcc/hash-traits.h +++ b/gcc/hash-traits.h @@ -28,6 +28,11 @@ struct typed_free_remove static inline void remove (Type *p); }; +template +struct typed_const_free_remove +{ + static inline void remove (const Type *p); +}; /* Remove with free. */ @@ -38,6 +43,13 @@ typed_free_remove ::remove (Type *p) free (p); } +template +inline void +typed_const_free_remove ::remove (const Type *p) +{ + free (const_cast (p)); +} + /* Helpful type for removing with delete. */ template @@ -305,6 +317,11 @@ struct ggc_ptr_hash : pointer_hash , ggc_remove {}; template struct ggc_cache_ptr_hash : pointer_hash , ggc_cache_remove {}; +/* Traits for string elements that should be freed when an element is + deleted. */ + +struct free_string_hash : string_hash, typed_const_free_remove {}; + /* Traits for string elements that should not be freed when an element is deleted. */ diff --git a/gcc/pass_manager.h b/gcc/pass_manager.h index 6484d2c8ebc..43484da2700 100644 --- a/gcc/pass_manager.h +++ b/gcc/pass_manager.h @@ -106,7 +106,7 @@ private: private: context *m_ctxt; - hash_map *m_name_to_pass_map; + hash_map *m_name_to_pass_map; /* References to all of the individual passes. These fields are generated via macro expansion. @@ -146,4 +146,3 @@ private: } // namespace gcc #endif /* ! GCC_PASS_MANAGER_H */ - diff --git a/gcc/passes.cc b/gcc/passes.cc index 00f856e0754..36e5b4ac45f 100644 --- a/gcc/passes.cc +++ b/gcc/passes.cc @@ -903,7 +903,7 @@ void pass_manager::register_pass_name (opt_pass *pass, const char *name) { if (!m_name_to_pass_map) - m_name_to_pass_map = new hash_map (256); + m_name_to_pass_map = new hash_map (256); if (m_name_to_pass_map->get (name)) return; /* Ignore plugin passes. */ @@ -1674,6 +1674,7 @@ pass_manager::~pass_manager () GCC_PASS_LISTS #undef DEF_PASS_LIST + delete m_name_to_pass_map; } /* If we are in IPA mode (i.e., current_function_decl is NULL), call @@ -1943,7 +1944,7 @@ pass_manager::dump_profile_report () const " |in count |out prob " "|in count |out prob " "|size |time |\n"); - + for (int i = 1; i < passes_by_id_size; i++) if (profile_record[i].run) {