]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix a merging scenario in merge_vreg_states().
authorIvo Raisr <ivosh@ivosh.net>
Wed, 27 Sep 2017 20:46:53 +0000 (22:46 +0200)
committerIvo Raisr <ivosh@ivosh.net>
Wed, 27 Sep 2017 20:46:53 +0000 (22:46 +0200)
When a vreg becomes dead in one If-Then-Else leg, and is never
referenced in the other leg, mark it as dead at the merge point.

The other scenarios will need the same treatment eventually.

VEX/priv/host_generic_reg_alloc3.c

index f910507f7e0b4f6fa47bf314fc297db50a521c9e..889766d530599d74a7ec62d129bc76bd0cc5aa8d 100644 (file)
@@ -1537,7 +1537,26 @@ static void merge_vreg_states(RegAllocChunk* chunk,
 
    switch (v1_src_state->disp) {
    case Unallocated:
-      vassert(v2_src_state->disp == Unallocated);
+      switch (v2_src_state->disp) {
+      case Unallocated:
+         /* Good. Nothing to do. */
+         break;
+      case Assigned:
+      case Spilled:
+         /* Should be dead by now. */
+         vassert(v2_src_state->dead_before <= chunk->next->ii_total_start);
+
+         HReg rreg2 = v2_src_state->rreg;
+         UInt r_idx = hregIndex(rreg2);
+         v2_src_state->disp = Unallocated;
+         v2_src_state->rreg = INVALID_HREG;
+         state2->rregs[r_idx].disp          = Free;
+         state2->rregs[r_idx].vreg          = INVALID_HREG;
+         state2->rregs[r_idx].eq_spill_slot = False;
+         break;
+      default:
+         vassert(0);
+      }
       break;
 
    case Assigned: