* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
@ 2012-12-18 15:38 ` rguenth at gcc dot gnu.org
2012-12-18 15:45 ` aldyh at gcc dot gnu.org
` (21 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-18 15:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P1
Status|UNCONFIRMED |NEW
Keywords| |build
Last reconfirmed| |2012-12-18
Ever Confirmed|0 |1
Summary|gcov-io.c uses builtins not |[4.8 Regression] gcov-io.c
|available in non-GCC |uses builtins not available
|compilers |in non-GCC compilers
Target Milestone|--- |4.8.0
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-18 15:37:47 UTC ---
Confirmed.
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
2012-12-18 15:38 ` [Bug gcov-profile/55734] [4.8 Regression] " rguenth at gcc dot gnu.org
@ 2012-12-18 15:45 ` aldyh at gcc dot gnu.org
2012-12-18 15:49 ` tejohnson at google dot com
` (20 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: aldyh at gcc dot gnu.org @ 2012-12-18 15:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #2 from Aldy Hernandez <aldyh at gcc dot gnu.org> 2012-12-18 15:45:17 UTC ---
I have a proposed patch here:
http://gcc.gnu.org/ml/gcc-patches/2012-12/msg00766.html
...which was deemed not sexy at all. So perhaps Richard or someone else can
suggest another route?
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
2012-12-18 15:38 ` [Bug gcov-profile/55734] [4.8 Regression] " rguenth at gcc dot gnu.org
2012-12-18 15:45 ` aldyh at gcc dot gnu.org
@ 2012-12-18 15:49 ` tejohnson at google dot com
2012-12-18 15:53 ` rguenth at gcc dot gnu.org
` (19 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: tejohnson at google dot com @ 2012-12-18 15:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #3 from Teresa Johnson <tejohnson at google dot com> 2012-12-18 15:49:03 UTC ---
In that thread, I had asked:
---
If you prefer, I can simply inline the popcount/clz functionality into
gcov-io.c directly (or at least when not using recent versions of
GCC). But that in fact would be duplicating the code, when I thought
Aldy's solution was trying to avoid that by providing the more general
interfaces.
Teresa
---
but didn't get a response. Richard, is that your preferred route for
fixing this issue?
Thanks,
Teresa
On Tue, Dec 18, 2012 at 7:45 AM, aldyh at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
>
> --- Comment #2 from Aldy Hernandez <aldyh at gcc dot gnu.org> 2012-12-18 15:45:17 UTC ---
> I have a proposed patch here:
>
> http://gcc.gnu.org/ml/gcc-patches/2012-12/msg00766.html
>
> ...which was deemed not sexy at all. So perhaps Richard or someone else can
> suggest another route?
>
> --
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (2 preceding siblings ...)
2012-12-18 15:49 ` tejohnson at google dot com
@ 2012-12-18 15:53 ` rguenth at gcc dot gnu.org
2012-12-18 15:54 ` rguenth at gcc dot gnu.org
` (18 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-18 15:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-18 15:52:40 UTC ---
(In reply to comment #3)
> In that thread, I had asked:
>
> ---
> If you prefer, I can simply inline the popcount/clz functionality into
> gcov-io.c directly (or at least when not using recent versions of
> GCC). But that in fact would be duplicating the code, when I thought
> Aldy's solution was trying to avoid that by providing the more general
> interfaces.
>
> Teresa
> ---
>
> but didn't get a response. Richard, is that your preferred route for
> fixing this issue?
We already have popcount_hwi and clz_hwi available. Can't you piggy-back
on that to provide (inline in gcov-io.c) popcountll and clzll? Why do
you need the long long variants anyway?
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (3 preceding siblings ...)
2012-12-18 15:53 ` rguenth at gcc dot gnu.org
@ 2012-12-18 15:54 ` rguenth at gcc dot gnu.org
2012-12-18 16:19 ` aldyh at gcc dot gnu.org
` (17 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-18 15:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-18 15:53:42 UTC ---
(In reply to comment #4)
> (In reply to comment #3)
> > In that thread, I had asked:
> >
> > ---
> > If you prefer, I can simply inline the popcount/clz functionality into
> > gcov-io.c directly (or at least when not using recent versions of
> > GCC). But that in fact would be duplicating the code, when I thought
> > Aldy's solution was trying to avoid that by providing the more general
> > interfaces.
> >
> > Teresa
> > ---
> >
> > but didn't get a response. Richard, is that your preferred route for
> > fixing this issue?
>
> We already have popcount_hwi and clz_hwi available. Can't you piggy-back
> on that to provide (inline in gcov-io.c) popcountll and clzll? Why do
> you need the long long variants anyway?
You don't seem to:
unsigned histo_bitvector[GCOV_HISTOGRAM_BITVECTOR_SIZE];
...
h_cnt += __builtin_popcountll (histo_bitvector[bv_ix]);
so just use popcount_hwi.
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (4 preceding siblings ...)
2012-12-18 15:54 ` rguenth at gcc dot gnu.org
@ 2012-12-18 16:19 ` aldyh at gcc dot gnu.org
2012-12-18 16:24 ` tejohnson at google dot com
` (16 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: aldyh at gcc dot gnu.org @ 2012-12-18 16:19 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #6 from Aldy Hernandez <aldyh at gcc dot gnu.org> 2012-12-18 16:19:33 UTC ---
Created attachment 28999
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28999
proposed patch
Oh, I didn't realize we always had the HWI variants available (inlined in
hwint.h).
Is something like this what you have in mind Richard?
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (5 preceding siblings ...)
2012-12-18 16:19 ` aldyh at gcc dot gnu.org
@ 2012-12-18 16:24 ` tejohnson at google dot com
2012-12-18 16:26 ` aldyh at gcc dot gnu.org
` (15 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: tejohnson at google dot com @ 2012-12-18 16:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #7 from Teresa Johnson <tejohnson at google dot com> 2012-12-18 16:24:13 UTC ---
On Tue, Dec 18, 2012 at 7:53 AM, rguenth at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
>
> --- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-18 15:53:42 UTC ---
> (In reply to comment #4)
>> (In reply to comment #3)
>> > In that thread, I had asked:
>> >
>> > ---
>> > If you prefer, I can simply inline the popcount/clz functionality into
>> > gcov-io.c directly (or at least when not using recent versions of
>> > GCC). But that in fact would be duplicating the code, when I thought
>> > Aldy's solution was trying to avoid that by providing the more general
>> > interfaces.
>> >
>> > Teresa
>> > ---
>> >
>> > but didn't get a response. Richard, is that your preferred route for
>> > fixing this issue?
>>
>> We already have popcount_hwi and clz_hwi available. Can't you piggy-back
>> on that to provide (inline in gcov-io.c) popcountll and clzll? Why do
>> you need the long long variants anyway?
>
> You don't seem to:
>
> unsigned histo_bitvector[GCOV_HISTOGRAM_BITVECTOR_SIZE];
> ...
> h_cnt += __builtin_popcountll (histo_bitvector[bv_ix]);
>
> so just use popcount_hwi.
The complication seems to be that hwint is not currently available for
libgcov.a (it is included by system.h which is not in libgcov.a). I
thought this was why Aldy took the approach of splitting out the hwi
routines into a separate helper file included by both hwint.c and
gcov-io. I can see if there is a way to simplify this, but I'm not
sure it is simple to include hwint into the gcov-io.c (and therefore
libgcov.a).
Teresa
>
> --
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug.
--
Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (6 preceding siblings ...)
2012-12-18 16:24 ` tejohnson at google dot com
@ 2012-12-18 16:26 ` aldyh at gcc dot gnu.org
2012-12-18 16:31 ` tejohnson at google dot com
` (14 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: aldyh at gcc dot gnu.org @ 2012-12-18 16:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
Aldy Hernandez <aldyh at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #28999|0 |1
is obsolete| |
--- Comment #8 from Aldy Hernandez <aldyh at gcc dot gnu.org> 2012-12-18 16:25:49 UTC ---
Created attachment 29000
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29000
proposed patch
Duh, they're always available. Like this?
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (7 preceding siblings ...)
2012-12-18 16:26 ` aldyh at gcc dot gnu.org
@ 2012-12-18 16:31 ` tejohnson at google dot com
2012-12-18 16:49 ` aldyh at redhat dot com
` (13 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: tejohnson at google dot com @ 2012-12-18 16:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #9 from Teresa Johnson <tejohnson at google dot com> 2012-12-18 16:31:08 UTC ---
On Tue, Dec 18, 2012 at 8:25 AM, aldyh at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
>
> Aldy Hernandez <aldyh at gcc dot gnu.org> changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> Attachment #28999|0 |1
> is obsolete| |
>
> --- Comment #8 from Aldy Hernandez <aldyh at gcc dot gnu.org> 2012-12-18 16:25:49 UTC ---
> Created attachment 29000
> --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29000
> proposed patch
>
> Duh, they're always available. Like this?
Things will build, but you will presumably get an undefined symbol in
your libgcov.a, which would result in an undefined trying to build
with -fprofile-generate. Can you verify that this works. I just
checked with a similar change, which yields:
$ nm gcc/libgcov.a | grep popc
U popcount_hwi
/home/tejohnson/extra/gcc_trunk_5_validate/bld-gcc/gcc/libgcov.a(_gcov.o):
In function `__gcov_read_summary':
libgcov.c:(.text+0x7f3): undefined reference to `popcount_hwi'
collect2: error: ld returned 1 exit status
Teresa
>
> --
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug.
--
Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (8 preceding siblings ...)
2012-12-18 16:31 ` tejohnson at google dot com
@ 2012-12-18 16:49 ` aldyh at redhat dot com
2012-12-18 22:41 ` aldyh at gcc dot gnu.org
` (12 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: aldyh at redhat dot com @ 2012-12-18 16:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #10 from Aldy Hernandez <aldyh at redhat dot com> 2012-12-18 16:48:40 UTC ---
Ah yes, now I remember. Yes, there is a problem with libgcov.a. I
wasn't seeing it because I was only building cc1. You are correct
Teresa, that is the reason for the gymnastics in my original patch.
houston:/build/trunkboot/gcc$ nm libgcov.a |grep popc
U popcount_hwi
I will let you and Richard sort it out :).
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (9 preceding siblings ...)
2012-12-18 16:49 ` aldyh at redhat dot com
@ 2012-12-18 22:41 ` aldyh at gcc dot gnu.org
2012-12-18 22:49 ` tejohnson at google dot com
` (11 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: aldyh at gcc dot gnu.org @ 2012-12-18 22:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #11 from Aldy Hernandez <aldyh at gcc dot gnu.org> 2012-12-18 22:41:13 UTC ---
Teresa, I think this is what you were referring to, and the reason for my
original patch:
houston:/build/trunkboot$ ./install/bin/gcc a.c -fprofile-generate
/home/build/trunkboot/install/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.0/libgcov.a(_gcov.o):
In function `gcov_histo_index':
libgcov.c:(.text+0x213): undefined reference to `clz_hwi'
/home/build/trunkboot/install/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.0/libgcov.a(_gcov.o):
In function `__gcov_read_summary':
libgcov.c:(.text+0x7f3): undefined reference to `popcount_hwi'
collect2: error: ld returned 1 exit status
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (10 preceding siblings ...)
2012-12-18 22:41 ` aldyh at gcc dot gnu.org
@ 2012-12-18 22:49 ` tejohnson at google dot com
2012-12-19 6:50 ` tejohnson at google dot com
` (10 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: tejohnson at google dot com @ 2012-12-18 22:49 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #12 from Teresa Johnson <tejohnson at google dot com> 2012-12-18 22:49:20 UTC ---
On Tue, Dec 18, 2012 at 2:41 PM, aldyh at gcc dot gnu.org <
gcc-bugzilla@gcc.gnu.org> wrote:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
>
> --- Comment #11 from Aldy Hernandez <aldyh at gcc dot gnu.org> 2012-12-18
> 22:41:13 UTC ---
> Teresa, I think this is what you were referring to, and the reason for my
> original patch:
>
> houston:/build/trunkboot$ ./install/bin/gcc a.c -fprofile-generate
>
> /home/build/trunkboot/install/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.0/libgcov.a(_gcov.o):
> In function `gcov_histo_index':
> libgcov.c:(.text+0x213): undefined reference to `clz_hwi'
>
> /home/build/trunkboot/install/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.0/libgcov.a(_gcov.o):
> In function `__gcov_read_summary':
> libgcov.c:(.text+0x7f3): undefined reference to `popcount_hwi'
> collect2: error: ld returned 1 exit status
>
Yep. I've got a patch in the works that is a slightly simplified version of
what you did. I'll send that a little later today once I get it tested.
Teresa
>
> --
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug.
>
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (11 preceding siblings ...)
2012-12-18 22:49 ` tejohnson at google dot com
@ 2012-12-19 6:50 ` tejohnson at google dot com
2012-12-19 9:43 ` rguenth at gcc dot gnu.org
` (9 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: tejohnson at google dot com @ 2012-12-19 6:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #13 from Teresa Johnson <tejohnson at google dot com> 2012-12-19 06:49:50 UTC ---
On Tue, Dec 18, 2012 at 2:48 PM, Teresa Johnson <tejohnson@google.com> wrote:
>
>
>
>
> On Tue, Dec 18, 2012 at 2:41 PM, aldyh at gcc dot gnu.org <gcc-bugzilla@gcc.gnu.org> wrote:
>>
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
>>
>> --- Comment #11 from Aldy Hernandez <aldyh at gcc dot gnu.org> 2012-12-18 22:41:13 UTC ---
>> Teresa, I think this is what you were referring to, and the reason for my
>> original patch:
>>
>> houston:/build/trunkboot$ ./install/bin/gcc a.c -fprofile-generate
>> /home/build/trunkboot/install/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.0/libgcov.a(_gcov.o):
>> In function `gcov_histo_index':
>> libgcov.c:(.text+0x213): undefined reference to `clz_hwi'
>> /home/build/trunkboot/install/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.8.0/libgcov.a(_gcov.o):
>> In function `__gcov_read_summary':
>> libgcov.c:(.text+0x7f3): undefined reference to `popcount_hwi'
>> collect2: error: ld returned 1 exit status
>
>
> Yep. I've got a patch in the works that is a slightly simplified version of what you did. I'll send that a little later today once I get it tested.
Here is the patch. I am doing some final regression testing on it, but
earlier testing and my own testing looked good. It is similar to what
Aldy did, pulling some of the hwi routines into a new hwint-helper.c
file. However, in this case, it is included normally into hwint.c, and
the routines are only pulled in as static copies to gcov-io.c when we
are building libgcov.a (in other cases gcov-io.c is being built when
system.h is included, which includes hwint.h already). In the case of
libgcov.a, I also had to add support for the fact that the HOST_*
variables that were being used in the hwint routines are not defined.
Richard, let me know if this looks like a reasonable approach. The
only other solution I had was to simply inline copies of popcount_hwi
and clz_hwi into gcov-io.c when we are building libgcov.a.
Thanks,
Teresa
2012-12-18 Teresa Johnson <tejohnson@google.com>
Aldy Hernandez <aldyh@redhat.com>
* hwint-helper.c (floor_log2): Moved from hwint.c
(ceil_log2): Ditto.
(exact_log2): Ditto.
(ctz_hwi): Ditto.
(clz_hwi): Ditto.
(ffs_hwi): Ditto.
(popcount_hwi): Ditto.
* gcov-io.c (gcov_read_summary): Invoke popcount_hwi.
(gcov_histo_index): Invoke clz_hwi.
* Makefile.in (hwint.o): Depend on hwint-helper.c
* hwint.c (floor_log2): Moved to hwint-helper.c
(ceil_log2): Ditto.
(exact_log2): Ditto.
(ctz_hwi): Ditto.
(clz_hwi): Ditto.
(ffs_hwi): Ditto.
(popcount_hwi): Ditto.
Index: hwint-helper.c
===================================================================
--- hwint-helper.c (revision 0)
+++ hwint-helper.c (revision 0)
@@ -0,0 +1,130 @@
+/* Supporting bit functions for older versions of GCC, and non-GCC
+ bootstrap compilers.
+
+ Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
+ 2012 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+Under Section 7 of GPL version 3, you are granted additional
+permissions described in the GCC Runtime Library Exception, version
+3.1, as published by the Free Software Foundation.
+
+You should have received a copy of the GNU General Public License and
+a copy of the GCC Runtime Library Exception along with this program;
+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+<http://www.gnu.org/licenses/>. */
+
+#if GCC_VERSION < 3004
+
+/* The functions clz_hwi, ctz_hwi, ffs_hwi, floor_log2, ceil_log2,
+ and exact_log2 are defined as inline functions in hwint.h
+ if GCC_VERSION >= 3004.
+ The definitions here are used for older versions of GCC and
+ non-GCC bootstrap compilers. */
+
+/* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
+ If X is 0, return -1. */
+
+HWINT_LINKAGE int
+floor_log2 (HWINT_TYPE x)
+{
+ int t = 0;
+
+ if (x == 0)
+ return -1;
+
+ if (HWINT_TYPE_SIZE > 64)
+ if (x >= (HWINT_TYPE) 1 << (t + 64))
+ t += 64;
+ if (HWINT_TYPE_SIZE > 32)
+ if (x >= ((HWINT_TYPE) 1) << (t + 32))
+ t += 32;
+ if (x >= ((HWINT_TYPE) 1) << (t + 16))
+ t += 16;
+ if (x >= ((HWINT_TYPE) 1) << (t + 8))
+ t += 8;
+ if (x >= ((HWINT_TYPE) 1) << (t + 4))
+ t += 4;
+ if (x >= ((HWINT_TYPE) 1) << (t + 2))
+ t += 2;
+ if (x >= ((HWINT_TYPE) 1) << (t + 1))
+ t += 1;
+
+ return t;
+}
+
+/* Given X, an unsigned number, return the largest Y such that 2**Y >= X. */
+
+HWINT_LINKAGE int
+ceil_log2 (HWINT_TYPE x)
+{
+ return floor_log2 (x - 1) + 1;
+}
+
+/* Return the logarithm of X, base 2, considering X unsigned,
+ if X is a power of 2. Otherwise, returns -1. */
+
+HWINT_LINKAGE int
+exact_log2 (HWINT_TYPE x)
+{
+ if (x != (x & -x))
+ return -1;
+ return floor_log2 (x);
+}
+
+/* Given X, an unsigned number, return the number of least significant bits
+ that are zero. When X == 0, the result is the word size. */
+
+HWINT_LINKAGE int
+ctz_hwi (HWINT_TYPE x)
+{
+ return x ? floor_log2 (x & -x) : HWINT_TYPE_SIZE;
+}
+
+/* Similarly for most significant bits. */
+
+HWINT_LINKAGE int
+clz_hwi (HWINT_TYPE x)
+{
+ return HWINT_TYPE_SIZE - 1 - floor_log2 (x);
+}
+
+/* Similar to ctz_hwi, except that the least significant bit is numbered
+ starting from 1, and X == 0 yields 0. */
+
+HWINT_LINKAGE int
+ffs_hwi (HWINT_TYPE x)
+{
+ return 1 + floor_log2 (x & -x);
+}
+
+/* Return the number of set bits in X. */
+
+HWINT_LINKAGE int
+popcount_hwi (HWINT_TYPE x)
+{
+ int i, ret = 0;
+ size_t bits = sizeof (x) * CHAR_BIT;
+
+ for (i = 0; i < (int)bits; i += 1)
+ {
+ ret += x & 1;
+ x >>= 1;
+ }
+
+ return ret;
+}
+
+#endif /* GCC_VERSION < 3004 */
Index: gcov-io.c
===================================================================
--- gcov-io.c (revision 194585)
+++ gcov-io.c (working copy)
@@ -517,6 +517,18 @@ gcov_read_string (void)
}
#endif
+#if IN_LIBGCOV
+#if GCC_VERSION < 3004
+#define HWINT_LINKAGE inline static
+#define HWINT_TYPE gcov_type_unsigned
+#define HWINT_TYPE_SIZE LONG_LONG_TYPE_SIZE
+#include "hwint-helper.c"
+#else
+#define popcount_hwi __builtin_popcountll
+#define clz_hwi __builtin_clzll
+#endif
+#endif
+
GCOV_LINKAGE void
gcov_read_summary (struct gcov_summary *summary)
{
@@ -538,7 +550,7 @@ gcov_read_summary (struct gcov_summary *summary)
for (bv_ix = 0; bv_ix < GCOV_HISTOGRAM_BITVECTOR_SIZE; bv_ix++)
{
histo_bitvector[bv_ix] = gcov_read_unsigned ();
- h_cnt += __builtin_popcountll (histo_bitvector[bv_ix]);
+ h_cnt += popcount_hwi (histo_bitvector[bv_ix]);
}
bv_ix = 0;
h_ix = 0;
@@ -642,7 +654,7 @@ gcov_histo_index (gcov_type value)
/* Find the place of the most-significant bit set. */
if (v > 0)
- r = 63 - __builtin_clzll (v);
+ r = 63 - clz_hwi (v);
/* If at most the 2 least significant bits are set (value is
0 - 3) then that value is our index into the lowest set of
Index: Makefile.in
===================================================================
--- Makefile.in (revision 194585)
+++ Makefile.in (working copy)
@@ -2701,7 +2701,7 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) corety
$(TREE_PRETTY_PRINT_H) opts-diagnostic.h $(COMMON_TARGET_H) \
tsan.h
-hwint.o : hwint.c $(CONFIG_H) $(SYSTEM_H) $(DIAGNOSTIC_CORE_H)
+hwint.o : hwint.c $(CONFIG_H) $(SYSTEM_H) $(DIAGNOSTIC_CORE_H) hwint-helper.c
passes.o : passes.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(RTL_H) $(FUNCTION_H) $(FLAGS_H) $(INPUT_H) $(INSN_ATTR_H) output.h \
Index: hwint.c
===================================================================
--- hwint.c (revision 194585)
+++ hwint.c (working copy)
@@ -23,109 +23,11 @@ along with GCC; see the file COPYING3. If not see
#include "system.h"
#include "diagnostic-core.h"
-#if GCC_VERSION < 3004
+#define HWINT_LINKAGE
+#define HWINT_TYPE unsigned HOST_WIDE_INT
+#define HWINT_TYPE_SIZE HOST_BITS_PER_WIDE_INT
+#include "hwint-helper.c"
-/* The functions clz_hwi, ctz_hwi, ffs_hwi, floor_log2, ceil_log2,
- and exact_log2 are defined as inline functions in hwint.h
- if GCC_VERSION >= 3004.
- The definitions here are used for older versions of GCC and
- non-GCC bootstrap compilers. */
-
-/* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
- If X is 0, return -1. */
-
-int
-floor_log2 (unsigned HOST_WIDE_INT x)
-{
- int t = 0;
-
- if (x == 0)
- return -1;
-
- if (HOST_BITS_PER_WIDE_INT > 64)
- if (x >= (unsigned HOST_WIDE_INT) 1 << (t + 64))
- t += 64;
- if (HOST_BITS_PER_WIDE_INT > 32)
- if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 32))
- t += 32;
- if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 16))
- t += 16;
- if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 8))
- t += 8;
- if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 4))
- t += 4;
- if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 2))
- t += 2;
- if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 1))
- t += 1;
-
- return t;
-}
-
-/* Given X, an unsigned number, return the largest Y such that 2**Y >= X. */
-
-int
-ceil_log2 (unsigned HOST_WIDE_INT x)
-{
- return floor_log2 (x - 1) + 1;
-}
-
-/* Return the logarithm of X, base 2, considering X unsigned,
- if X is a power of 2. Otherwise, returns -1. */
-
-int
-exact_log2 (unsigned HOST_WIDE_INT x)
-{
- if (x != (x & -x))
- return -1;
- return floor_log2 (x);
-}
-
-/* Given X, an unsigned number, return the number of least significant bits
- that are zero. When X == 0, the result is the word size. */
-
-int
-ctz_hwi (unsigned HOST_WIDE_INT x)
-{
- return x ? floor_log2 (x & -x) : HOST_BITS_PER_WIDE_INT;
-}
-
-/* Similarly for most significant bits. */
-
-int
-clz_hwi (unsigned HOST_WIDE_INT x)
-{
- return HOST_BITS_PER_WIDE_INT - 1 - floor_log2(x);
-}
-
-/* Similar to ctz_hwi, except that the least significant bit is numbered
- starting from 1, and X == 0 yields 0. */
-
-int
-ffs_hwi (unsigned HOST_WIDE_INT x)
-{
- return 1 + floor_log2 (x & -x);
-}
-
-/* Return the number of set bits in X. */
-
-int
-popcount_hwi (unsigned HOST_WIDE_INT x)
-{
- int i, ret = 0;
- size_t bits = sizeof (x) * CHAR_BIT;
-
- for (i = 0; i < bits; i += 1)
- {
- ret += x & 1;
- x >>= 1;
- }
-
- return ret;
-}
-
-#endif /* GCC_VERSION < 3004 */
-
/* Compute the absolute value of X. */
HOST_WIDE_INT
>
> Teresa
>>
>>
>> --
>> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
>> ------- You are receiving this mail because: -------
>> You are on the CC list for the bug.
>
>
>
>
> --
> Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413
>
--
Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (12 preceding siblings ...)
2012-12-19 6:50 ` tejohnson at google dot com
@ 2012-12-19 9:43 ` rguenth at gcc dot gnu.org
2012-12-19 13:07 ` rguenth at gcc dot gnu.org
` (8 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-19 9:43 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #14 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-19 09:43:27 UTC ---
(In reply to comment #10)
> Ah yes, now I remember. Yes, there is a problem with libgcov.a. I
> wasn't seeing it because I was only building cc1. You are correct
> Teresa, that is the reason for the gymnastics in my original patch.
>
> houston:/build/trunkboot/gcc$ nm libgcov.a |grep popc
> U popcount_hwi
>
> I will let you and Richard sort it out :).
libgcov should be built by stage1 gcc already and thus has the builtins
available.
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (13 preceding siblings ...)
2012-12-19 9:43 ` rguenth at gcc dot gnu.org
@ 2012-12-19 13:07 ` rguenth at gcc dot gnu.org
2012-12-19 15:08 ` tejohnson at google dot com
` (7 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-12-19 13:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #15 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-19 13:07:01 UTC ---
(In reply to comment #14)
> (In reply to comment #10)
> > Ah yes, now I remember. Yes, there is a problem with libgcov.a. I
> > wasn't seeing it because I was only building cc1. You are correct
> > Teresa, that is the reason for the gymnastics in my original patch.
> >
> > houston:/build/trunkboot/gcc$ nm libgcov.a |grep popc
> > U popcount_hwi
> >
> > I will let you and Richard sort it out :).
>
> libgcov should be built by stage1 gcc already and thus has the builtins
> available.
To be more explicit - use #if IN_LIBGCOV to guard __builtin_popcountll vs.
popcount_hwi.
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (14 preceding siblings ...)
2012-12-19 13:07 ` rguenth at gcc dot gnu.org
@ 2012-12-19 15:08 ` tejohnson at google dot com
2012-12-19 16:40 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: tejohnson at google dot com @ 2012-12-19 15:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #16 from Teresa Johnson <tejohnson at google dot com> 2012-12-19 15:07:54 UTC ---
On Wed, Dec 19, 2012 at 5:07 AM, rguenth at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
>
> --- Comment #15 from Richard Biener <rguenth at gcc dot gnu.org> 2012-12-19 13:07:01 UTC ---
> (In reply to comment #14)
>> (In reply to comment #10)
>> > Ah yes, now I remember. Yes, there is a problem with libgcov.a. I
>> > wasn't seeing it because I was only building cc1. You are correct
>> > Teresa, that is the reason for the gymnastics in my original patch.
>> >
>> > houston:/build/trunkboot/gcc$ nm libgcov.a |grep popc
>> > U popcount_hwi
>> >
>> > I will let you and Richard sort it out :).
>>
>> libgcov should be built by stage1 gcc already and thus has the builtins
>> available.
>
> To be more explicit - use #if IN_LIBGCOV to guard __builtin_popcountll vs.
> popcount_hwi.
Ah, yes, this fact escaped me and makes things much simpler. Running
the regression tests right now, will send patch as soon as they
finish...
Thanks,
Teresa
>
> --
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug.
--
Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (15 preceding siblings ...)
2012-12-19 15:08 ` tejohnson at google dot com
@ 2012-12-19 16:40 ` jakub at gcc dot gnu.org
2012-12-19 16:48 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-12-19 16:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #17 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-12-19 16:39:56 UTC ---
I guess a problem of such approach is if not in libgcov.a and HOST_WIDE_INT is
smaller than long long (or for clz even not exactly 64-bit).
For popcount, I wonder why the code uses __builtin_popcountll at all, when the
value is unsigned int, it should just use __builtin_popcount and I think we can
safely assume that HOST_WIDE_INT is at least as wide as int.
So just using either popcount_hwi or __builtin_popcount (no ll) should be fine.
For clz, there is:
if (v > 0)
r = 63 - __builtin_clzll (v);
i.e. it relies on clzll having exactly 64-bit argument. For __builtin_clzll
perhaps the assumption is fine, for clz_hwi not so. So you need some extra
code to implement clz_ll on top of clz_hwi if HWI is smaller than 64-bit.
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (16 preceding siblings ...)
2012-12-19 16:40 ` jakub at gcc dot gnu.org
@ 2012-12-19 16:48 ` jakub at gcc dot gnu.org
2012-12-19 16:58 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-12-19 16:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-12-19 16:48:00 UTC ---
Perhaps
if (v > 0)
{
#if IN_LIBGCOV
r = 63 - __builtin_clzll (v);
#else
if (sizeof (v) <= sizeof (HOST_WIDE_INT))
r = floor_log2 (v);
else if (sizeof (v) == 2 * sizeof (HOST_WIDE_INT))
{
r = v >> HOST_BITS_PER_WIDE_INT;
if (r)
r = floor_log2 (r) + HOST_BITS_PER_WIDE_INT;
else
r = floor_log2 (v);
}
else
gcc_unreachable ();
#endif
}
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (17 preceding siblings ...)
2012-12-19 16:48 ` jakub at gcc dot gnu.org
@ 2012-12-19 16:58 ` jakub at gcc dot gnu.org
2012-12-19 17:08 ` tejohnson at google dot com
` (3 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-12-19 16:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #19 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-12-19 16:57:31 UTC ---
Of course v >> HOST_BITS_PER_WIDE_INT can't be assigned to r, it needs some new
temporary, with unsigned HOST_WIDE_INT or gcov_type_unsigned type (and use that
temporary instead in if (r) and floor_log2 (r).
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (18 preceding siblings ...)
2012-12-19 16:58 ` jakub at gcc dot gnu.org
@ 2012-12-19 17:08 ` tejohnson at google dot com
2012-12-19 17:35 ` tejohnson at google dot com
` (2 subsequent siblings)
22 siblings, 0 replies; 24+ messages in thread
From: tejohnson at google dot com @ 2012-12-19 17:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #20 from Teresa Johnson <tejohnson at google dot com> 2012-12-19 17:07:51 UTC ---
On Wed, Dec 19, 2012 at 8:39 AM, jakub at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
>
> Jakub Jelinek <jakub at gcc dot gnu.org> changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> CC| |jakub at gcc dot gnu.org
>
> --- Comment #17 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-12-19 16:39:56 UTC ---
> I guess a problem of such approach is if not in libgcov.a and HOST_WIDE_INT is
> smaller than long long (or for clz even not exactly 64-bit).
> For popcount, I wonder why the code uses __builtin_popcountll at all, when the
> value is unsigned int, it should just use __builtin_popcount and I think we can
> safely assume that HOST_WIDE_INT is at least as wide as int.
> So just using either popcount_hwi or __builtin_popcount (no ll) should be fine.
ok.
> For clz, there is:
> if (v > 0)
> r = 63 - __builtin_clzll (v);
> i.e. it relies on clzll having exactly 64-bit argument. For __builtin_clzll
> perhaps the assumption is fine, for clz_hwi not so. So you need some extra
> code to implement clz_ll on top of clz_hwi if HWI is smaller than 64-bit.
ok, thanks for pointing out this issue. I'll try out the solution you posted.
Teresa
>
> --
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug.
--
Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (19 preceding siblings ...)
2012-12-19 17:08 ` tejohnson at google dot com
@ 2012-12-19 17:35 ` tejohnson at google dot com
2012-12-20 14:31 ` tejohnson at gcc dot gnu.org
2012-12-20 14:56 ` jakub at gcc dot gnu.org
22 siblings, 0 replies; 24+ messages in thread
From: tejohnson at google dot com @ 2012-12-19 17:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #21 from Teresa Johnson <tejohnson at google dot com> 2012-12-19 17:35:08 UTC ---
On Wed, Dec 19, 2012 at 8:48 AM, jakub at gcc dot gnu.org
<gcc-bugzilla@gcc.gnu.org> wrote:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
>
> --- Comment #18 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-12-19 16:48:00 UTC ---
> Perhaps
> if (v > 0)
> {
> #if IN_LIBGCOV
> r = 63 - __builtin_clzll (v);
> #else
> if (sizeof (v) <= sizeof (HOST_WIDE_INT))
> r = floor_log2 (v);
> else if (sizeof (v) == 2 * sizeof (HOST_WIDE_INT))
> {
> r = v >> HOST_BITS_PER_WIDE_INT;
> if (r)
> r = floor_log2 (r) + HOST_BITS_PER_WIDE_INT;
> else
> r = floor_log2 (v);
> }
> else
> gcc_unreachable ();
> #endif
> }
Also, I have changed the runtime size checks into preprocessor checks,
both to increase the speed and also to avoid compile-time errors about
shifting by the size of the variable (on v >> HOST_BITS_PER_WIDE_INT).
Thanks,
Teresa
>
> --
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You are on the CC list for the bug.
--
Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (20 preceding siblings ...)
2012-12-19 17:35 ` tejohnson at google dot com
@ 2012-12-20 14:31 ` tejohnson at gcc dot gnu.org
2012-12-20 14:56 ` jakub at gcc dot gnu.org
22 siblings, 0 replies; 24+ messages in thread
From: tejohnson at gcc dot gnu.org @ 2012-12-20 14:31 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
--- Comment #22 from tejohnson at gcc dot gnu.org 2012-12-20 14:31:18 UTC ---
Author: tejohnson
Date: Thu Dec 20 14:31:09 2012
New Revision: 194634
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194634
Log:
Fix PR gcov-profile/55734 by using methods from hwint.c instead of
builtins, to handle non-GCC and older versions of GCC. When building
libgcov.a, however, hwint.c is not available, but we are always using
the bootstrapped compiler and can therefore use the builtins.
Use __builtin_popcount instead of __builtin_popcountll, since we
are operating on an int.
Use floor_log2 directly, instead of clz_hwi for the non-libgcov case,
and handle situations where the size of the gcov_type is bigger than
HOST_WIDE_INT. Verified that the various cases compiled by forcing
different HOST_BITS_PER_WIDE_INT values.
2012-12-20 Teresa Johnson <tejohnson@google.com>
Jakub Jelinek <jakub@redhat.com>
PR gcov-profile/55734
* gcov-io.c (gcov_read_summary): Use __builtin_popcount instead
of __builtin_popcountll when building libgcov.a, otherwise use
popcount_hwi.
(gcov_histo_index): When not building libgcov.a, use floor_log2
instead of __builtin_clzll.
Modified:
trunk/gcc/ChangeLog
trunk/gcc/gcov-io.c
^ permalink raw reply [flat|nested] 24+ messages in thread
* [Bug gcov-profile/55734] [4.8 Regression] gcov-io.c uses builtins not available in non-GCC compilers
2012-12-18 15:33 [Bug gcov-profile/55734] New: gcov-io.c uses builtins not available in non-GCC compilers aldyh at gcc dot gnu.org
` (21 preceding siblings ...)
2012-12-20 14:31 ` tejohnson at gcc dot gnu.org
@ 2012-12-20 14:56 ` jakub at gcc dot gnu.org
22 siblings, 0 replies; 24+ messages in thread
From: jakub at gcc dot gnu.org @ 2012-12-20 14:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55734
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
--- Comment #23 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-12-20 14:56:27 UTC ---
Fixed.
^ permalink raw reply [flat|nested] 24+ messages in thread