public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-4900] Improve efficiency of copying section from another tree
@ 2020-11-11 3:59 Jeff Law
0 siblings, 0 replies; only message in thread
From: Jeff Law @ 2020-11-11 3:59 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:4656461585bfd0b925553995a9d114645f1287d0
commit r11-4900-g4656461585bfd0b925553995a9d114645f1287d0
Author: Strager Neds <strager.nds@gmail.com>
Date: Tue Nov 10 20:57:04 2020 -0700
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.
Diff:
---
gcc/cgraph.h | 9 +++++++--
gcc/symtab.c | 31 ++++++++++++++++++++++++++-----
2 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 2e62db2a33b..97287bda6f0 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -330,6 +330,10 @@ public:
use set_section. */
void set_section_for_node (const char *section);
+ /* Like set_section_for_node, but copying the section name from another
+ node. */
+ void set_section_for_node (const symtab_node &other);
+
/* Set initialization priority to PRIORITY. */
void set_init_priority (priority_type priority);
@@ -646,8 +650,9 @@ protected:
void *data,
bool include_overwrite);
private:
- /* Worker for set_section. */
- static bool set_section (symtab_node *n, void *s);
+ /* Workers for set_section. */
+ static bool set_section_from_string (symtab_node *n, void *s);
+ static bool set_section_from_node (symtab_node *n, void *o);
/* Worker for symtab_resolve_alias. */
static bool set_implicit_section (symtab_node *n, void *);
diff --git a/gcc/symtab.c b/gcc/symtab.c
index c84259f1032..393d6b07870 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. */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-11-11 3:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11 3:59 [gcc r11-4900] Improve efficiency of copying section from another tree Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).