Blame SOURCES/valgrind-3.14.0-s390x-fix-reg-alloc-vr-vs-fpr.patch

560544
commit 71002d8a5111d02ce8049c55017a8d948c820e35
560544
Author: Andreas Arnez <arnez@linux.ibm.com>
560544
Date:   Thu Oct 25 13:47:12 2018 +0200
560544
560544
    Bug 400490 s390x: Fix register allocation for VRs vs FPRs
560544
    
560544
    On s390x, if vector registers are available, they are fed to the register
560544
    allocator as if they were separate from the floating-point registers.  But
560544
    in fact the FPRs are embedded in the VRs.  So for instance, if both f3 and
560544
    v3 are allocated and used at the same time, corruption will result.
560544
    
560544
    This is fixed by offering only the non-overlapping VRs, v16 to v31, to the
560544
    register allocator instead.
560544
560544
diff --git a/VEX/priv/host_s390_defs.c b/VEX/priv/host_s390_defs.c
560544
index 6c22ac8..98ac938 100644
560544
--- a/VEX/priv/host_s390_defs.c
560544
+++ b/VEX/priv/host_s390_defs.c
560544
@@ -59,7 +59,6 @@ static UInt s390_tchain_load64_len(void);
560544
 
560544
 /* A mapping from register number to register index */
560544
 static Int gpr_index[16];  // GPR regno -> register index
560544
-static Int fpr_index[16];  // FPR regno -> register index
560544
 static Int vr_index[32];   // VR regno -> register index
560544
 
560544
 HReg
560544
@@ -73,7 +72,7 @@ s390_hreg_gpr(UInt regno)
560544
 HReg
560544
 s390_hreg_fpr(UInt regno)
560544
 {
560544
-   Int ix = fpr_index[regno];
560544
+   Int ix = vr_index[regno];
560544
    vassert(ix >= 0);
560544
    return mkHReg(/*virtual*/False, HRcFlt64, regno, ix);
560544
 }
560544
@@ -463,11 +462,9 @@ getRRegUniverse_S390(void)
560544
 
560544
    RRegUniverse__init(ru);
560544
 
560544
-   /* Assign invalid values to the gpr/fpr/vr_index */
560544
+   /* Assign invalid values to the gpr/vr_index */
560544
    for (UInt i = 0; i < sizeof gpr_index / sizeof gpr_index[0]; ++i)
560544
       gpr_index[i] = -1;
560544
-   for (UInt i = 0; i < sizeof fpr_index / sizeof fpr_index[0]; ++i)
560544
-      fpr_index[i] = -1;
560544
    for (UInt i = 0; i < sizeof vr_index / sizeof vr_index[0]; ++i)
560544
       vr_index[i] = -1;
560544
 
560544
@@ -494,17 +491,17 @@ getRRegUniverse_S390(void)
560544
 
560544
    ru->allocable_start[HRcFlt64] = ru->size;
560544
    for (UInt regno = 8; regno <= 15; ++regno) {
560544
-      fpr_index[regno] = ru->size;
560544
+      vr_index[regno] = ru->size;
560544
       ru->regs[ru->size++] = s390_hreg_fpr(regno);
560544
    }
560544
    for (UInt regno = 0; regno <= 7; ++regno) {
560544
-      fpr_index[regno] = ru->size;
560544
+      vr_index[regno] = ru->size;
560544
       ru->regs[ru->size++] = s390_hreg_fpr(regno);
560544
    }
560544
    ru->allocable_end[HRcFlt64] = ru->size - 1;
560544
 
560544
    ru->allocable_start[HRcVec128] = ru->size;
560544
-   for (UInt regno = 0; regno <= 31; ++regno) {
560544
+   for (UInt regno = 16; regno <= 31; ++regno) {
560544
       vr_index[regno] = ru->size;
560544
       ru->regs[ru->size++] = s390_hreg_vr(regno);
560544
    }
560544
@@ -527,12 +524,12 @@ getRRegUniverse_S390(void)
560544
    /* Sanity checking */
560544
    for (UInt i = 0; i < sizeof gpr_index / sizeof gpr_index[0]; ++i)
560544
       vassert(gpr_index[i] >= 0);
560544
-   for (UInt i = 0; i < sizeof fpr_index / sizeof fpr_index[0]; ++i)
560544
-      vassert(fpr_index[i] >= 0);
560544
    for (UInt i = 0; i < sizeof vr_index / sizeof vr_index[0]; ++i)
560544
       vassert(vr_index[i] >= 0);
560544
                  
560544
    initialised = True;
560544
+
560544
+   RRegUniverse__check_is_sane(ru);
560544
    return ru;
560544
 }
560544