Skip to contentSkip to conversation

Update usage chain for dead instruction

PATCH In review Christopher Li 2 participants 2 messages Jan 17, 2007 Sparse checker

lore
Share & tools
lore

Christopher Li

author maintainer
#0 lore raw

PATCH 1/1 Update usage chain for dead instruction

This patch address some of the dead instruction
left in the usage chain.

flow.c +1 -0
Index: sparse/flow.c
===================================================================
@@ -195,6 +195,7 @@ try_to_rewrite_target:
 	if (bb_list_size(target->parents) != 1)
 		return retval;
 	insert_branch(target, insn, final);
+	kill_instruction(insn);
 	return 1;
 }
 
simplify.c +5 -0
Index: sparse/simplify.c
===================================================================
@@ -217,6 +217,11 @@ void kill_instruction(struct instruction
 		kill_use(&insn->src2);
 		kill_use(&insn->src3);
 		return;
+	case OP_BR:
+		insn->bb = NULL;
+		repeat_phase |= REPEAT_CSE;
+		if (insn->cond)
+			kill_use(&insn->cond);
 	}
 }
 
#1 lore raw
Quoted 2 lines · Christopher Li

This patch address some of the dead instruction
left in the usage chain.

Merged.

One minor style note:

simplify.c void kill_instruction(struct instruction · line 226

Quoted 13 lines
simplify.c +5 -0
@@ -217,6 +217,11 @@ void kill_instruction(struct instruction
 		kill_use(&insn->src2);
 		kill_use(&insn->src3);
 		return;
+	case OP_BR:
+		insn->bb = NULL;
+		repeat_phase |= REPEAT_CSE;
+		if (insn->cond)
+			kill_use(&insn->cond);
 	}
 }

Despite redundancy, please include return or break statements in the last case of a switch, to make modifications less error-prone.

- Josh Triplett