diff mbox series

fix killing OP_ASM

Message ID 20201204161349.68272-1-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series fix killing OP_ASM | expand

Commit Message

Luc Van Oostenryck Dec. 4, 2020, 4:13 p.m. UTC
Currently OP_ASMs are only handled by default in kill_insn().
In consequence, the usage is not removed from their inputs,
possibly leaving dead pseudos.

Fix this by removing the usage on the input pseudos.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 simplify.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/simplify.c b/simplify.c
index 851f94209975..a877b693b610 100644
--- a/simplify.c
+++ b/simplify.c
@@ -308,6 +308,15 @@  static void kill_use_list(struct pseudo_list *list)
 	} END_FOR_EACH_PTR(p);
 }
 
+static void kill_asm(struct instruction *insn)
+{
+	struct asm_constraint *con;
+
+	FOR_EACH_PTR(insn->asm_rules->inputs, con) {
+		kill_use(&con->pseudo);
+	} END_FOR_EACH_PTR(con);
+}
+
 ///
 // kill an instruction
 // @insn: the instruction to be killed
@@ -373,6 +382,12 @@  int kill_insn(struct instruction *insn, int force)
 		kill_use(&insn->target);
 		break;
 
+	case OP_ASM:
+		if (!force)
+			return 0;
+		kill_asm(insn);
+		break;
+
 	case OP_ENTRY:
 		/* ignore */
 		return 0;