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 profile: make clean make CFLAGS="$(CFLAGS) -fprofile-generate" make check make mostlyclean make CFLAGS="$(CFLAGS) -fprofile-use" CLEANFILES = *.gcda *.gcno Paolo