]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
s390x regtest: Add missing memory clobbers in mvc.c
authorAndreas Arnez <arnez@linux.ibm.com>
Fri, 8 Nov 2024 13:52:11 +0000 (14:52 +0100)
committerAndreas Arnez <arnez@linux.ibm.com>
Fri, 8 Nov 2024 13:52:11 +0000 (14:52 +0100)
The s390x test case `mvc' was seen to fail when using gcc -O3 with GCC
11.4.1 on Ubuntu:

   mvc: mvc.c:48: main: Assertion `full[i] == 'x'' failed.

In this case the compiler optimized the assertion check away, because it
doesn't consider `full' to be affected by the inline assembly.

Add memory clobbers to fix this.

none/tests/s390x/mvc.c

index 636234b579a3e55d52c2164893654471c84b7dd5..2da8758fc34cef596f08fdfd5070c9580a474c07 100644 (file)
@@ -34,7 +34,7 @@ int main(void)
    printf("before: target = |%s|\n", target);
    asm volatile( "mvi 0(%0),'x'\n\t"        // target[1] = 'x'
                  "mvc 1(2,%0),0(%0)\n\t"    // target[2:3] = target[1]
-                 :: "a" (target+1));
+                 :: "a" (target+1) : "memory");
    printf("after:  target = |%s|\n", target);
 
    /* Destructive overlap #3 */
@@ -42,7 +42,7 @@ int main(void)
    memset(full, '-', sizeof full);
    full[0] = 'x';
    asm volatile( "mvc 1(256,%0),0(%0)\n\t"     // full[1:256] = full[0]
-                 :: "a" (full));
+                 :: "a" (full) : "memory");
    /* Verify: the first 256+1 characters should be 'x' followed by '-' */
    for (i = 0; i <= 256; ++i)
       assert(full[i] == 'x');