From patchwork Tue Dec 20 10:09:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 707400 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3tjYS15Vdwz9sCG for ; Tue, 20 Dec 2016 21:09:53 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="emd0G4Lr"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; q=dns; s=default; b= chCuksg/qgVUabbIYhSU3w4xJrJvhbjPwkSI6zIpO15GmtscXHlhV6tFoYvs/49L CqquA2wbWc1kpDR+I3b+IGMJOGtWdturG2BuwbNtGQZx/RS9fgt/rvbaznb/qOI2 QfMBISlnZYG65dULY/MI+hfrry6P9rFsBo51dWGG7sA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; s=default; bh=AQKmMl GHwaXwNS203ag0WtM3xu0=; b=emd0G4LrOrN8a2wLRAoCAnyzGFL2kItJ6ybroE eglcKz7DOERD1B8lZqJlqVY3sfS0IyOLBCJSzpf8BvMi5RTiFaZB2ikMZn5y53mh 2WmcMh3gcRbh2QpYbeEAN2e1HWDKCityoDgUmMmDDKEMLeaddMiYnDmUKSigy5h4 zVXrY= Received: (qmail 4275 invoked by alias); 20 Dec 2016 10:09:46 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 4263 invoked by uid 89); 20 Dec 2016 10:09:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.0 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=sk:fweimer, U*fweimer, fweimer@redhat.com, fweimerredhatcom X-HELO: mx1.redhat.com Date: Tue, 20 Dec 2016 11:09:41 +0100 To: libc-alpha@sourceware.org Subject: [PATCH COMMITTED] Do not require memset elimination in explicit_bzero test User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20161220100941.B4FA5401BD5F6@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) Some targets fail to apply dead store elimination to the memset call in setup_ordinary_clear. Before this commit, this causes the test case to fail. Instead, the test case now logs lack of memset elimination as an informational message. 2016-12-20 Florian Weimer Do not require memset elimination in explicit_bzero test. * string/tst-xbzero-opt.c (prepare_test_buffer): Force inlining. (enum test_expectation): Add NO_EXPECTATIONS. (subtests): NO_EXPECTATIONS for ordinary clear. (check_test_buffer): Handle NO_EXPECTATIONS. * string/Makefile (CFLAGS-tst-xbzero-opt.c): Compile with -O3. diff --git a/string/Makefile b/string/Makefile index 9a8b46d..0816277 100644 --- a/string/Makefile +++ b/string/Makefile @@ -71,6 +71,7 @@ CFLAGS-tst-strlen.c = -fno-builtin CFLAGS-stratcliff.c = -fno-builtin CFLAGS-test-ffs.c = -fno-builtin CFLAGS-tst-inlcall.c = -fno-builtin +CFLAGS-tst-xbzero-opt.c = -O3 ifeq ($(run-built-tests),yes) $(objpfx)tst-svc-cmp.out: tst-svc.expect $(objpfx)tst-svc.out diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c index 312857e..3fcaf28 100644 --- a/string/tst-xbzero-opt.c +++ b/string/tst-xbzero-opt.c @@ -88,19 +88,19 @@ static const unsigned char test_pattern[16] = between preparing it and letting it go out of scope, and we expect to find it. This confirms that the test buffer does get filled in and we can find it from the stack buffer. In the "ordinary_clear" - case, we clear it using memset, and we expect to find it. This - confirms that the compiler can optimize out block clears in this - context; if it can't, the real test might be succeeding for the - wrong reason. Finally, the "explicit_clear" case uses - explicit_bzero and expects _not_ to find the test buffer, which is - the real test. */ + case, we clear it using memset. Depending on the target, the + compiler may not be able to apply dead store elimination to the + memset call, so the test does not fail if the memset is not + eliminated. Finally, the "explicit_clear" case uses explicit_bzero + and expects _not_ to find the test buffer, which is the real + test. */ static ucontext_t uc_main, uc_co; /* Always check the test buffer immediately after filling it; this makes externally visible side effects depend on the buffer existing and having been filled in. */ -static void +static inline __attribute__ ((always_inline)) void prepare_test_buffer (unsigned char *buf) { for (unsigned int i = 0; i < PATTERN_REPS; i++) @@ -133,7 +133,10 @@ setup_explicit_clear (void) explicit_bzero (buf, TEST_BUFFER_SIZE); } -enum test_expectation { EXPECT_NONE, EXPECT_SOME, EXPECT_ALL }; +enum test_expectation + { + EXPECT_NONE, EXPECT_SOME, EXPECT_ALL, NO_EXPECTATIONS + }; struct subtest { void (*setup_subtest) (void); @@ -145,7 +148,9 @@ static const struct subtest *cur_subtest; static const struct subtest subtests[] = { { setup_no_clear, "no clear", EXPECT_SOME }, - { setup_ordinary_clear, "ordinary clear", EXPECT_SOME }, + /* The memset may happen or not, depending on compiler + optimizations. */ + { setup_ordinary_clear, "ordinary clear", NO_EXPECTATIONS }, { setup_explicit_clear, "explicit clear", EXPECT_NONE }, { 0, 0, -1 } }; @@ -225,6 +230,11 @@ check_test_buffer (enum test_expectation expected, } break; + case NO_EXPECTATIONS: + printf ("INFO: %s/%s: found %d patterns%s\n", label, stage, cnt, + cnt == 0 ? " (memset not eliminated)" : ""); + break; + default: printf ("ERROR: %s/%s: invalid value for 'expected' = %d\n", label, stage, (int)expected);