[COMMITTED] Add missing consts to arguments in call_summary

Message ID 20261103160048.261718-2-josef.melcr@suse.com
State New
Headers
Series [COMMITTED] Add missing consts to arguments in call_summary |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-aarch64-bootstrap fail Patch failed to apply
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-arm-bootstrap fail Patch failed to apply

Commit Message

Josef Melcr Nov. 3, 2026, 4 p.m. UTC
  Hi,
this patch adds marks the arguments of call_summary methods const, as
well as making get_uid const.  I didn't attempt to make add consts to
hooks, as they are frequently overridden.

Bootstrapped and regtested, pushed as obvious.

Best regards,
Josef

-- >8 --

I noticed that the edges passed to call_summary are not marked const,
even though they can be.  This patch adds the const qualifiers to the
arguments and to cgraph_edge methods these functions call.

gcc/ChangeLog:

	* cgraph.h: Add consts to cgraph_edge::get_uid.
	* symbol-summary.h (call_summary::get_create): Take const
	cgraph_edge pointer.
	(call_summary::get): Likewise.
	(call_summary::remove): Likewise.
	(call_summary::exists): Likewise.

Signed-off-by: Josef Melcr <josef.melcr@suse.com>
---
 gcc/cgraph.h         | 2 +-
 gcc/symbol-summary.h | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)
  

Patch

diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index cad7fb3c127..e1341343fdd 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -2112,7 +2112,7 @@  public:
   bool maybe_hot_p (sreal scale);
 
   /* Get unique identifier of the edge.  */
-  inline int get_uid ()
+  inline int get_uid () const
   {
     return m_uid;
   }
diff --git a/gcc/symbol-summary.h b/gcc/symbol-summary.h
index 01c2a481a7c..7c037eb9a3b 100644
--- a/gcc/symbol-summary.h
+++ b/gcc/symbol-summary.h
@@ -695,7 +695,7 @@  public:
 
   /* Getter for summary callgraph edge pointer.
      If a summary for an edge does not exist, it will be created.  */
-  T* get_create (cgraph_edge *edge)
+  T* get_create (const cgraph_edge *edge)
   {
     bool existed;
     T **v = &m_map.get_or_insert (edge->get_uid (), &existed);
@@ -706,7 +706,7 @@  public:
   }
 
   /* Getter for summary callgraph edge pointer.  */
-  T* get (cgraph_edge *edge) ATTRIBUTE_PURE
+  T* get (const cgraph_edge *edge) ATTRIBUTE_PURE
   {
     T **v = m_map.get (edge->get_uid ());
     return v == NULL ? NULL : *v;
@@ -714,7 +714,7 @@  public:
 
   /* Remove edge from summary.  */
   using call_summary_base<T>::remove;
-  void remove (cgraph_edge *edge)
+  void remove (const cgraph_edge *edge)
   {
     int uid = edge->get_uid ();
     T **v = m_map.get (uid);
@@ -726,7 +726,7 @@  public:
   }
 
   /* Return true if a summary for the given EDGE already exists.  */
-  bool exists (cgraph_edge *edge)
+  bool exists (const cgraph_edge *edge)
   {
     return m_map.get (edge->get_uid ()) != NULL;
   }