diff mbox

[RFC,27/48] mem2reg: extract kill_pseudo_stores()

Message ID 20170823201554.90551-28-luc.vanoostenryck@gmail.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Luc Van Oostenryck Aug. 23, 2017, 8:15 p.m. UTC
---
 mem2reg.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
diff mbox

Patch

diff --git a/mem2reg.c b/mem2reg.c
index 7096a4bf2..4671d4710 100644
--- a/mem2reg.c
+++ b/mem2reg.c
@@ -148,6 +148,17 @@  static void kill_store(struct instruction *insn)
 	}
 }
 
+static void kill_pseudo_stores(pseudo_t pseudo)
+{
+	struct pseudo_user *pu;
+
+	FOR_EACH_PTR(pseudo->users, pu) {
+		struct instruction *insn = pu->insn;
+		if (insn->opcode == OP_STORE)
+			kill_store(insn);
+	} END_FOR_EACH_PTR(pu);
+}
+
 /* Kill a pseudo that is dead on exit from the bb */
 static void kill_dead_stores(pseudo_t pseudo, unsigned long generation, struct basic_block *bb, int local)
 {
@@ -307,11 +318,7 @@  static void promote_symbol(struct entrypoint *ep, struct symbol *sym)
 
 	/* If we converted all the loads, remove the stores. They are dead */
 	if (all && !mod) {
-		FOR_EACH_PTR(pseudo->users, pu) {
-			struct instruction *insn = pu->insn;
-			if (insn->opcode == OP_STORE)
-				kill_store(insn);
-		} END_FOR_EACH_PTR(pu);
+		return kill_pseudo_stores(pseudo);
 	} else {
 		/*
 		 * If we couldn't take the shortcut, see if we can at least kill some