aboutsummaryrefslogtreecommitdiff
path: root/gcc/symtab.c
diff options
context:
space:
mode:
authorStrager Neds <strager.nds@gmail.com>2020-11-10 20:57:04 -0700
committerJeff Law <law@redhat.com>2020-11-10 20:59:01 -0700
commit4656461585bfd0b925553995a9d114645f1287d0 (patch)
treef7d27f8f244e4b089232ef01ee4280ac759b737f /gcc/symtab.c
parente79de0682e6cb6fe041a22f81cc65375c8c15bff (diff)
downloadgcc-4656461585bfd0b925553995a9d114645f1287d0.zip
gcc-4656461585bfd0b925553995a9d114645f1287d0.tar.gz
gcc-4656461585bfd0b925553995a9d114645f1287d0.tar.bz2
Improve efficiency of copying section from another tree
gcc/ * cgraph.h (symtab_node::set_section_for_node): Declare new overload. (symtab_node::set_section_from_string): Rename from set_section. (symtab_node::set_section_from_node): Declare. * symtab.c (symtab_node::set_section_for_node): Define new overload. (symtab_node::set_section_from_string): Rename from set_section. (symtab_node::set_section_from_node): Define. (symtab_node::set_section): Call renamed set_section_from_string. (symtab_node::set_section): Call new set_section_from_node.
Diffstat (limited to 'gcc/symtab.c')
-rw-r--r--gcc/symtab.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/gcc/symtab.c b/gcc/symtab.c
index c84259f..393d6b0 100644
--- a/gcc/symtab.c
+++ b/gcc/symtab.c
@@ -1668,15 +1668,37 @@ symtab_node::set_section_for_node (const char *section)
}
}
-/* Worker for set_section. */
+void
+symtab_node::set_section_for_node (const symtab_node &other)
+{
+ if (x_section == other.x_section)
+ return;
+ if (get_section () && other.get_section ())
+ gcc_checking_assert (strcmp (get_section (), other.get_section ()) != 0);
+ release_section_hash_entry (x_section);
+ if (other.x_section)
+ x_section = retain_section_hash_entry (other.x_section);
+ else
+ x_section = NULL;
+}
+
+/* Workers for set_section. */
bool
-symtab_node::set_section (symtab_node *n, void *s)
+symtab_node::set_section_from_string (symtab_node *n, void *s)
{
n->set_section_for_node ((char *)s);
return false;
}
+bool
+symtab_node::set_section_from_node (symtab_node *n, void *o)
+{
+ const symtab_node &other = *static_cast<const symtab_node *> (o);
+ n->set_section_for_node (other);
+ return false;
+}
+
/* Set section of symbol and its aliases. */
void
@@ -1684,15 +1706,14 @@ symtab_node::set_section (const char *section)
{
gcc_assert (!this->alias || !this->analyzed);
call_for_symbol_and_aliases
- (symtab_node::set_section, const_cast<char *>(section), true);
+ (symtab_node::set_section_from_string, const_cast<char *>(section), true);
}
void
symtab_node::set_section (const symtab_node &other)
{
- const char *section = other.get_section ();
call_for_symbol_and_aliases
- (symtab_node::set_section, const_cast<char *>(section), true);
+ (symtab_node::set_section_from_node, const_cast<symtab_node *>(&other), true);
}
/* Return the initialization priority. */