[ccache] Support for -fprofile-generate, -fprofile-use, -fprofile-arcs

Justin Lebar justin.lebar at gmail.com
Wed Aug 10 10:48:33 MDT 2011


On Wed, Aug 10, 2011 at 11:22 AM, Chris AtLee <chris at atlee.ca> wrote:
> Ah ha!
>
> What does this mean for whether it's worthwhile to include the .gcda
> contents in the hash when using -fprofile-use, and therefore if it's
> worthwhile to cache -fprofile-use at all?

This suggests to me that it might be worthwhile to include the .gcda
file in the hash.  You'd presumably get cache hits on simple files, or
files whose code is never run.

I'd be curious whether Firefox gets any cache hits during -fprofile-use.

-Justin

> On Wed, Aug 10, 2011 at 11:03 AM, Justin Lebar <justin.lebar at gmail.com> wrote:
>> gcda files are cumulative.  Try
>>
>> $ ./test; md5sum test.gcda; rm test.gcda
>> hello world
>> 1c14199a60b2e5b9e6f1e96360adc40c  test.gcda
>> $ ./test; md5sum test.gcda; rm test.gcda
>> hello world
>> 1c14199a60b2e5b9e6f1e96360adc40c  test.gcda
>>
>> On Wed, Aug 10, 2011 at 10:51 AM, Chris AtLee <chris at atlee.ca> wrote:
>>> On Mon, Aug 8, 2011 at 4:24 PM, Justin Lebar <justin.lebar at gmail.com> wrote:
>>>>> The .gcda files themselves aren't cached, their contents are used to
>>>>> calculate the hash for a -fprofile-use run. So if the .o file doesn't
>>>>> exist, and you have the same .gcda file, you get a cache hit.
>>>>
>>>> Ah, I see.  What if the .o file does exist?  Why should that matter,
>>>> if gcc is going to overwrite it anyway?
>>>
>>> It doesn't really matter..my point was that hopefully your make
>>> dependencies are set up so you're not calling gcc if you don't need
>>> to.
>>>
>>>> You mentioned earlier that a simple program without branches or loops
>>>> didn't generate the same .gcda files when the program was run twice.
>>>> Would you mind including that code?  I wrote a pretty simple testcase
>>>> and observed the opposite result.  Maybe it's different in different
>>>> versions of gcc or something.
>>>
>>> I have a simple hello world program. Even if I comment out the printf
>>> I get different .gcda files after each run.
>>>
>>> #include <stdio.h>
>>>
>>> int main() {
>>>    printf("hello world\n");
>>>    return 0;
>>> }
>>>
>>> gcc -fprofile-generate   -c -o test.o test.c
>>> gcc -fprofile-generate  test.o   -o test
>>> ./test; md5sum test.gcda
>>> 83fdede120951b154184271416082bdb  test.gcda
>>> ./test; md5sum test.gcda
>>> 230d10c340e6ae068a7d65b4bc355472  test.gcda
>>>
>>
>


More information about the ccache mailing list