[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: profile-directed optimization

From: Paolo Bonzini
Subject: Re: profile-directed optimization
Date: Sun, 21 Sep 2008 16:44:02 +0200
User-agent: Thunderbird (Macintosh/20080707)

Bruno Haible wrote:
> Paolo Bonzini wrote:
>>> But the compiler does not know that fstrcmp is called millions of time and
>>> that this piece of code needs to be optimized for speed rather than for 
>>> space.
>> If doing profile-directed optimization, it does know.
> However, it is impractical: I never used profile-directed optimization with
> GCC so far, because the steps to put it in place are prohibitive. In a
> just-in-time compiler, such as in Java or C# virtual machines, it can be
> implemented transparently. But in a C compiler, it requires the following
> steps (taken from the GCC manual):
>         * Compile the source files with `-fprofile-arcs' plus
>           optimization and code generation options.
>         * Link your object files with `-lgcov' or `-fprofile-arcs' (the
>           latter implies the former).
>         * Run the program on a representative workload to generate the
>           arc profile information.
>         * Compile the source files again with the same optimization and
>           code generation options plus `-fbranch-probabilities'

.PHONY: profile
        make clean
        make CFLAGS="$(CFLAGS) -fprofile-generate"
        make check
        make mostlyclean
        make CFLAGS="$(CFLAGS) -fprofile-use"

CLEANFILES = *.gcda *.gcno


reply via email to

[Prev in Thread] Current Thread [Next in Thread]