public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] benchtest: Fix clang issues on benchmarks build Date: Fri, 3 Jun 2022 14:12:21 +0000 (GMT) [thread overview] Message-ID: <20220603141221.D9F003850852@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2a00910c0ea2b677f93ab5b2776a59ae0b3f95e7 commit 2a00910c0ea2b677f93ab5b2776a59ae0b3f95e7 Author: Adhemerval Zanella <adhemerval.zanella@linaro.org> Date: Mon Apr 4 09:35:29 2022 -0300 benchtest: Fix clang issues on benchmarks build Diff: --- benchtests/bench-malloc-thread.c | 6 ++++++ benchtests/bench-pthread-locks.c | 14 +++++++++++--- benchtests/bench-pthread-mutex-locks.c | 14 +++++++++++--- benchtests/bench-strchr.c | 9 ++++++++- 4 files changed, 36 insertions(+), 7 deletions(-) diff --git a/benchtests/bench-malloc-thread.c b/benchtests/bench-malloc-thread.c index 81228392ef..04a9c631e7 100644 --- a/benchtests/bench-malloc-thread.c +++ b/benchtests/bench-malloc-thread.c @@ -26,6 +26,7 @@ #include <sys/time.h> #include <sys/resource.h> #include <unistd.h> +#include <libc-diag.h> #include "bench-timing.h" #include "json-lib.h" @@ -63,7 +64,12 @@ get_block_size (unsigned int rand_data) float min_pow = powf (dist_min, exponent + 1); float max_pow = powf (dist_max, exponent + 1); + /* clang warns that converting from int to float (upper_bound) changes value + from 2147483647 to 2147483648. It does not matter in tests below. */ + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wimplicit-const-int-float-conversion"); float r = (float) rand_data / RAND_MAX; + DIAG_POP_NEEDS_COMMENT_CLANG; return (unsigned int) powf ((max_pow - min_pow) * r + min_pow, 1 / (exponent + 1)); diff --git a/benchtests/bench-pthread-locks.c b/benchtests/bench-pthread-locks.c index d7419f511c..e57c122120 100644 --- a/benchtests/bench-pthread-locks.c +++ b/benchtests/bench-pthread-locks.c @@ -61,8 +61,12 @@ typedef timing_t (*test_t)(long, int); total time each test iteration takes, so as to not swamp the useful timings. */ -#pragma GCC push_options -#pragma GCC optimize(1) +#ifdef __clang__ +# pragma clang optimize off +#else +# pragma GCC push_options +# pragma GCC optimize(1) +#endif static int __attribute__((noinline)) fibonacci (int i) @@ -81,7 +85,11 @@ do_filler (void) memcpy (buf1, buf2, f); } -#pragma GCC pop_options +#ifdef __clang__ +# pragma clang optimize on +#else +# pragma GCC pop_options +#endif static timing_t test_mutex (long iters, int filler) diff --git a/benchtests/bench-pthread-mutex-locks.c b/benchtests/bench-pthread-mutex-locks.c index 1685b9dd1f..00b2ed32b0 100644 --- a/benchtests/bench-pthread-mutex-locks.c +++ b/benchtests/bench-pthread-mutex-locks.c @@ -37,8 +37,12 @@ static pthread_barrier_t barrier; #define START_ITERS 1000 -#pragma GCC push_options -#pragma GCC optimize(1) +#ifdef __clang__ +# pragma clang optimize off +#else +# pragma GCC push_options +# pragma GCC optimize(1) +#endif static int __attribute__ ((noinline)) fibonacci (int i) { @@ -64,7 +68,11 @@ do_filler_shared (void) memcpy (buf1, buf2, f); } -#pragma GCC pop_options +#ifdef __clang__ +# pragma clang optimize on +#else +# pragma GCC pop_options +#endif #define UNIT_WORK_CRT do_filler_shared () #define UNIT_WORK_NON_CRT do_filler () diff --git a/benchtests/bench-strchr.c b/benchtests/bench-strchr.c index 54c5c283ae..a417131e2c 100644 --- a/benchtests/bench-strchr.c +++ b/benchtests/bench-strchr.c @@ -16,6 +16,8 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ +#include <libc-diag.h> + #define TEST_MAIN #ifndef WIDE # ifdef USE_FOR_STRCHRNUL @@ -98,7 +100,7 @@ do_one_rand_plus_branch_test (json_ctx_t *json_ctx, impl_t *impl, const CHAR *s, const CHAR *c) { size_t i, iters = INNER_LOOP_ITERS_LARGE; - int must_execute = 0; + volatile int must_execute = 0; timing_t start, stop, cur; TIMING_NOW (start); for (i = 0; i < iters; ++i) @@ -163,7 +165,12 @@ do_rand_test (json_ctx_t *json_ctx, size_t align, size_t pos, size_t len, buf[align + len] = 0; buf[align + pos] = 1; + /* clang warns that converting from int to float (upper_bound) changes value + from 2147483647 to 2147483648. It does not matter in tests below. */ + DIAG_PUSH_NEEDS_COMMENT_CLANG; + DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wimplicit-const-int-float-conversion"); perc_zero_int = perc_zero * RAND_MAX; + DIAG_POP_NEEDS_COMMENT_CLANG; for (i = 0; i < NUM_SEARCH_CHARS; ++i) { if (rand () > perc_zero_int)
next reply other threads:[~2022-06-03 14:12 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-06-03 14:12 Adhemerval Zanella [this message] -- strict thread matches above, loose matches on Subject: below -- 2022-06-09 21:26 Adhemerval Zanella 2022-06-09 13:23 Adhemerval Zanella 2022-05-13 14:26 Adhemerval Zanella 2022-05-12 19:40 Adhemerval Zanella 2022-05-10 18:30 Adhemerval Zanella 2022-04-29 14:10 Adhemerval Zanella 2022-04-04 13:01 Adhemerval Zanella
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220603141221.D9F003850852@sourceware.org \ --to=azanella@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).