Change the return value of LibVEX_{Chain,UnChain,PatchProfInc}.
These functions now always return the address range that was
patched. Therefore, these functions no longer need knowledge
about I-cache coherency of the host system.


git-svn-id: svn://svn.valgrind.org/vex/trunk@2545 8f6e269a-dfd6-0310-a8e1-e2731360e62c
diff --git a/priv/host_amd64_defs.c b/priv/host_amd64_defs.c
index cdb8ab6..44029ea 100644
--- a/priv/host_amd64_defs.c
+++ b/priv/host_amd64_defs.c
@@ -3595,7 +3595,7 @@
       *(ULong*)(&p[2]) = Ptr_to_ULong(place_to_jump_to);
       p[12] = 0xE3;
    }
-   VexInvalRange vir = {0, 0};
+   VexInvalRange vir = { (HWord)place_to_chain, 13 };
    return vir;
 }
 
@@ -3659,7 +3659,7 @@
    p[10] = 0x41;
    p[11] = 0xFF;
    p[12] = 0xD3;
-   VexInvalRange vir = {0, 0};
+   VexInvalRange vir = { (HWord)place_to_unchain, 13 };
    return vir;
 }
 
@@ -3693,7 +3693,7 @@
    p[7] = imm64 & 0xFF; imm64 >>= 8;
    p[8] = imm64 & 0xFF; imm64 >>= 8;
    p[9] = imm64 & 0xFF; imm64 >>= 8;
-   VexInvalRange vir = {0, 0};
+   VexInvalRange vir = { (HWord)place_to_patch, 13 };
    return vir;
 }
 
diff --git a/priv/host_s390_defs.c b/priv/host_s390_defs.c
index 8a99ad0..01056ef 100644
--- a/priv/host_s390_defs.c
+++ b/priv/host_s390_defs.c
@@ -7643,7 +7643,7 @@
 }
 
 /* CODE points to the code sequence as generated by s390_tchain_load64.
-   Change the loaded value to VALUE. Return pointer to the byte following
+   Change the loaded value to IMM64. Return pointer to the byte following
    the patched code sequence. */
 static UChar *
 s390_tchain_patch_load64(UChar *code, ULong imm64)
@@ -8130,9 +8130,11 @@
 
    s390_tchain_verify_load64(code_to_patch, S390_REGNO_TCHAIN_SCRATCH, 0);
 
-   s390_tchain_patch_load64(code_to_patch, Ptr_to_ULong(location_of_counter));
+   UChar *p = s390_tchain_patch_load64(code_to_patch,
+                                       Ptr_to_ULong(location_of_counter));
 
-   VexInvalRange vir = {0, 0};
+   UInt len = p - (UChar *)code_to_patch;
+   VexInvalRange vir = { (HWord)code_to_patch, len };
    return vir;
 }
 
@@ -8216,7 +8218,8 @@
       /* There is not need to emit a BCR here, as it is already there. */
    }
 
-   VexInvalRange vir = {0, 0};
+   UInt len = p - (UChar *)place_to_chain;
+   VexInvalRange vir = { (HWord)place_to_chain, len };
    return vir;
 }
 
@@ -8286,7 +8289,8 @@
    if (uses_short_form)
       s390_emit_BCR(p, S390_CC_ALWAYS, S390_REGNO_TCHAIN_SCRATCH);
 
-   VexInvalRange vir = {0, 0};
+   UInt len = p - (UChar *)place_to_unchain;
+   VexInvalRange vir = { (HWord)place_to_unchain, len };
    return vir;
 }
 
diff --git a/priv/host_x86_defs.c b/priv/host_x86_defs.c
index efd511e..2d61060 100644
--- a/priv/host_x86_defs.c
+++ b/priv/host_x86_defs.c
@@ -3349,7 +3349,7 @@
    /* sanity check on the delta -- top 32 are all 0 or all 1 */
    delta >>= 32;
    vassert(delta == 0LL || delta == -1LL);
-   VexInvalRange vir = {0, 0};
+   VexInvalRange vir = { (HWord)place_to_chain, 7 };
    return vir;
 }
 
@@ -3392,7 +3392,7 @@
    *(UInt*)(&p[1]) = (UInt)Ptr_to_ULong(disp_cp_chain_me);
    p[5] = 0xFF;
    p[6] = 0xD2;
-   VexInvalRange vir = {0, 0};
+   VexInvalRange vir = { (HWord)place_to_unchain, 7 };
    return vir;
 }
 
@@ -3428,7 +3428,7 @@
    p[10] = imm32 & 0xFF; imm32 >>= 8;
    p[11] = imm32 & 0xFF; imm32 >>= 8;
    p[12] = imm32 & 0xFF; imm32 >>= 8;
-   VexInvalRange vir = {0, 0};
+   VexInvalRange vir = { (HWord)place_to_patch, 14 };
    return vir;
 }
 
diff --git a/pub/libvex.h b/pub/libvex.h
index 3692770..9d7f8bd 100644
--- a/pub/libvex.h
+++ b/pub/libvex.h
@@ -699,14 +699,12 @@
 /*--- Patch existing translations                     ---*/
 /*-------------------------------------------------------*/
 
-/* Indicates a host address range for which callers to the functions
-   below must request I-D cache syncing after the call.  ::len == 0 is
-   ambiguous -- it could mean either zero bytes or the entire address
-   space, so we mean the former. */
+/* A host address range that was modified by the functions below. 
+   Callers must request I-cache syncing after the call as appropriate. */
 typedef
    struct {
       HWord start;
-      HWord len;
+      HWord len;     /* always > 0 */
    }
    VexInvalRange;