[PATCH 01/16] extract nbr_users() from unssa.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This small helper was used in unssa.c but is useful elsewhere too.

Move it as an inline function to linearize.h and rename it to
'nbr_users()' since it is close to the existing 'has_users()'.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 linearize.h | 5 +++++
 simplify.c  | 2 +-
 unssa.c     | 7 +------
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/linearize.h b/linearize.h
index 092e1ac23..2bd6185a6 100644
--- a/linearize.h
+++ b/linearize.h
@@ -338,6 +338,11 @@ static inline int has_users(pseudo_t p)
 	return pseudo_user_list_size(p->users) != 0;
 }
 
+static inline int nbr_users(pseudo_t p)
+{
+	return pseudo_user_list_size(p->users);
+}
+
 static inline struct pseudo_user *alloc_pseudo_user(struct instruction *insn, pseudo_t *pp)
 {
 	struct pseudo_user *user = __alloc_pseudo_user(0);
diff --git a/simplify.c b/simplify.c
index 3a5ae9331..1ac000e52 100644
--- a/simplify.c
+++ b/simplify.c
@@ -843,7 +843,7 @@ static int simplify_associative_binop(struct instruction *insn)
 		return 0;
 	if (!simple_pseudo(def->src2))
 		return 0;
-	if (pseudo_user_list_size(def->target->users) != 1)
+	if (nbr_users(def->target) != 1)
 		return 0;
 	switch_pseudo(def, &def->src1, insn, &insn->src2);
 	return REPEAT_CSE;
diff --git a/unssa.c b/unssa.c
index e7c9154d5..334ffa470 100644
--- a/unssa.c
+++ b/unssa.c
@@ -34,11 +34,6 @@
 #include <assert.h>
 
 
-static inline int nbr_pseudo_users(pseudo_t p)
-{
-	return ptr_list_size((struct ptr_list *)p->users);
-}
-
 static int simplify_phi_node(struct instruction *phi, pseudo_t tmp)
 {
 	pseudo_t target = phi->target;
@@ -95,7 +90,7 @@ static void replace_phi_node(struct instruction *phi)
 		src = def->phi_src;
 		if (src->type != PSEUDO_REG)
 			continue;
-		switch (nbr_pseudo_users(src)) {
+		switch (nbr_users(src)) {
 			struct instruction *insn;
 		case 1:
 			insn = src->def;
-- 
2.18.0

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux