[25/59] libctf: add ctf_forwardable_kind

Message ID 20200630233146.338613-26-nick.alcock@oracle.com
State New
Headers show
Series
  • Deduplicating CTF linker
Related show

Commit Message

H.J. Lu via Binutils June 30, 2020, 11:31 p.m.
The internals of the deduplicator want to know if something is a type
that can have a forward to it fairly often, often enough that inlining
it brings a noticeable performance gain.  Convert the one place in
libctf that can already benefit, even though it doesn't bring any sort
of performance gain there.

libctf/
	* ctf-inlines.h (ctf_forwardable_kind): New.
	* ctf-create.c (ctf_add_forward): Use it.
---
 libctf/ctf-create.c  | 2 +-
 libctf/ctf-inlines.h | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

-- 
2.27.0.247.g3dff7de930

Patch

diff --git a/libctf/ctf-create.c b/libctf/ctf-create.c
index c13b83d4d3b..d50367d6de3 100644
--- a/libctf/ctf-create.c
+++ b/libctf/ctf-create.c
@@ -1241,7 +1241,7 @@  ctf_add_forward (ctf_file_t *fp, uint32_t flag, const char *name,
   ctf_dtdef_t *dtd;
   ctf_id_t type = 0;
 
-  if (kind != CTF_K_STRUCT && kind != CTF_K_UNION && kind != CTF_K_ENUM)
+  if (!ctf_forwardable_kind (kind))
     return (ctf_set_errno (fp, ECTF_NOTSUE));
 
   /* If the type is already defined or exists as a forward tag, just
diff --git a/libctf/ctf-inlines.h b/libctf/ctf-inlines.h
index 4bec97b11b3..3b912bd9a25 100644
--- a/libctf/ctf-inlines.h
+++ b/libctf/ctf-inlines.h
@@ -40,6 +40,12 @@  ctf_get_ctt_size (const ctf_file_t *fp,
   return (fp->ctf_fileops->ctfo_get_ctt_size (fp, tp, sizep, incrementp));
 }
 
+static inline int
+ctf_forwardable_kind (int kind)
+{
+  return (kind == CTF_K_STRUCT || kind == CTF_K_UNION || kind == CTF_K_ENUM);
+}
+
 
 static inline int
 ctf_dynhash_cinsert (ctf_dynhash_t *h, const void *k, const void *v)