public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Fix string/tst-xbzero-opt if build with gcc head.
@ 2018-07-12 14:22 Stefan Liebler
  2018-07-12 16:42 ` Zack Weinberg
  0 siblings, 1 reply; 9+ messages in thread
From: Stefan Liebler @ 2018-07-12 14:22 UTC (permalink / raw)
  To: GNU C Library

[-- Attachment #1: Type: text/plain, Size: 823 bytes --]

Fix string/tst-xbzero-opt is build with gcc head.

On s390x, the test string/tst-xbzero-opt is failing if build with GCC head:
FAIL: no clear/prepare: expected 32 got 0
FAIL: no clear/test: expected some got 0
FAIL: ordinary clear/prepare: expected 32 got 0
INFO: ordinary clear/test: found 0 patterns (memset not eliminated)
PASS: explicit clear/prepare: expected 32 got 32
PASS: explicit clear/test: expected 0 got 0

In setup_no_clear / setup_ordinary_clear, GCC is omitting the memcpy 
loop in prepare_test_buffer. Thus count_test_patterns does not find any 
of the test_pattern.

This patch introduces a compiler barrier just after filling the buffer.

If okay, shall this be committed before or after the release?

Bye
Stefan

---

ChangeLog:

	* string/tst-xbzero-opt.c (prepare_test_buffer):
	Add compiler barrier.

[-- Attachment #2: 20180712_string_tst_xbzero_opt.patch --]
[-- Type: text/x-patch, Size: 1514 bytes --]

commit 65f9b078c5053faa93e1f572282463685a869864
Author: Stefan Liebler <stli@linux.ibm.com>
Date:   Thu Jul 12 16:07:26 2018 +0200

    Fix string/tst-xbzero-opt if build with gcc head.
    
    On s390x, the test string/tst-xbzero-opt is failing if build with gcc head:
    FAIL: no clear/prepare: expected 32 got 0
    FAIL: no clear/test: expected some got 0
    FAIL: ordinary clear/prepare: expected 32 got 0
    INFO: ordinary clear/test: found 0 patterns (memset not eliminated)
    PASS: explicit clear/prepare: expected 32 got 32
    PASS: explicit clear/test: expected 0 got 0
    
    In setup_no_clear / setup_ordinary_clear, GCC is omitting the memcpy loop
    in prepare_test_buffer. Thus count_test_patterns does not find any of the
    test_pattern.
    
    This patch introduces a compiler barrier just after filling the buffer
    and the filling of the test_pattern is not omitted.
    
    ChangeLog:
    
            * string/tst-xbzero-opt.c (prepare_test_buffer): Add compiler barrier.

diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
index cf7041f37a..4c2be0c197 100644
--- a/string/tst-xbzero-opt.c
+++ b/string/tst-xbzero-opt.c
@@ -106,6 +106,9 @@ prepare_test_buffer (unsigned char *buf)
   for (unsigned int i = 0; i < PATTERN_REPS; i++)
     memcpy (buf + i*PATTERN_SIZE, test_pattern, PATTERN_SIZE);
 
+  /* Force the compiler to really copy the pattern to buf.  */
+  __asm__ __volatile__ ("" ::: "memory");
+
   if (swapcontext (&uc_co, &uc_main))
     abort ();
 }

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-07-26 15:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-12 14:22 Fix string/tst-xbzero-opt if build with gcc head Stefan Liebler
2018-07-12 16:42 ` Zack Weinberg
2018-07-16 11:05   ` Stefan Liebler
2018-07-16 12:36     ` Zack Weinberg
2018-07-16 13:13       ` Stefan Liebler
2018-07-16 13:18         ` Zack Weinberg
2018-07-23  6:42           ` Stefan Liebler
2018-07-26 13:33     ` Carlos O'Donell
2018-07-26 15:13       ` [COMMITTED] " Stefan Liebler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).