public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/clang] benchtest: Fix clang issues on benchmarks build
@ 2022-06-09 21:26 Adhemerval Zanella
  0 siblings, 0 replies; 8+ messages in thread
From: Adhemerval Zanella @ 2022-06-09 21:26 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e5462edbf3cf839c7b603f621ac479bc8703252f

commit e5462edbf3cf839c7b603f621ac479bc8703252f
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)


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

* [glibc/azanella/clang] benchtest: Fix clang issues on benchmarks build
@ 2022-06-09 13:23 Adhemerval Zanella
  0 siblings, 0 replies; 8+ messages in thread
From: Adhemerval Zanella @ 2022-06-09 13:23 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e5462edbf3cf839c7b603f621ac479bc8703252f

commit e5462edbf3cf839c7b603f621ac479bc8703252f
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)


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

* [glibc/azanella/clang] benchtest: Fix clang issues on benchmarks build
@ 2022-06-03 14:12 Adhemerval Zanella
  0 siblings, 0 replies; 8+ messages in thread
From: Adhemerval Zanella @ 2022-06-03 14:12 UTC (permalink / raw)
  To: glibc-cvs

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)


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

* [glibc/azanella/clang] benchtest: Fix clang issues on benchmarks build
@ 2022-05-13 14:26 Adhemerval Zanella
  0 siblings, 0 replies; 8+ messages in thread
From: Adhemerval Zanella @ 2022-05-13 14:26 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0a7386f72330c3e94e929a2e2490287f6907d064

commit 0a7386f72330c3e94e929a2e2490287f6907d064
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)


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

* [glibc/azanella/clang] benchtest: Fix clang issues on benchmarks build
@ 2022-05-12 19:40 Adhemerval Zanella
  0 siblings, 0 replies; 8+ messages in thread
From: Adhemerval Zanella @ 2022-05-12 19:40 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ff4356175c9e0d773bd43cb743b67736ad58f54d

commit ff4356175c9e0d773bd43cb743b67736ad58f54d
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)


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

* [glibc/azanella/clang] benchtest: Fix clang issues on benchmarks build
@ 2022-05-10 18:30 Adhemerval Zanella
  0 siblings, 0 replies; 8+ messages in thread
From: Adhemerval Zanella @ 2022-05-10 18:30 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ba960d416b674429d57e123104f1f0c1d7e6eeac

commit ba960d416b674429d57e123104f1f0c1d7e6eeac
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)


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

* [glibc/azanella/clang] benchtest: Fix clang issues on benchmarks build
@ 2022-04-29 14:10 Adhemerval Zanella
  0 siblings, 0 replies; 8+ messages in thread
From: Adhemerval Zanella @ 2022-04-29 14:10 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=555b3811adc9c26be65bec1bcbbd37ff2af7d485

commit 555b3811adc9c26be65bec1bcbbd37ff2af7d485
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-strchr.c        |  9 ++++++++-
 3 files changed, 25 insertions(+), 4 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-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)


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

* [glibc/azanella/clang] benchtest: Fix clang issues on benchmarks build
@ 2022-04-04 13:01 Adhemerval Zanella
  0 siblings, 0 replies; 8+ messages in thread
From: Adhemerval Zanella @ 2022-04-04 13:01 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e4487da242bc5a8c5b97c271f299f5b0f6114bc3

commit e4487da242bc5a8c5b97c271f299f5b0f6114bc3
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-strchr.c        |  9 ++++++++-
 3 files changed, 25 insertions(+), 4 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-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)


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

end of thread, other threads:[~2022-06-09 21:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-09 21:26 [glibc/azanella/clang] benchtest: Fix clang issues on benchmarks build Adhemerval Zanella
  -- strict thread matches above, loose matches on Subject: below --
2022-06-09 13:23 Adhemerval Zanella
2022-06-03 14:12 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

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).