I want to clarify a few things that probably weren't clear in my initial
question.
I'm asking primarily about a feature which I think is new in GCC 4.3. I
downloaded, built, and tested just version 4.4.0 in case there has been
recent further work on this new feature, but I'm asking this question
primarily about version 4.3. If you can help me understand how 4.3
behaves, please don't decide not to reply based on my use of 4.4.0 for
my own testing.
In the example below, I would like to know if there is some way to
define rarely_executed() so it's use will tell the compiler that xxx4
will be executed far less often than xxx2 and xxx5. I thought
__attribute__((cold)) might do that and I tried that. But if some other
way of defining rarely_executed() will do that, I'd like to know.
I would also like to know whether __attribute__((cold)) does or doesn't
change the compilation of the block containing the call. The
documentation seems to say it does. I looked at the gcc source code and
there seems to be code to achieve that. But I haven't found the effect
in the actual generated asm code.
John Fine wrote:
I am using (GCC) 4.4.0 20080319 (experimental)
inline void __attribute__((cold)) rarely_execute() {}
while (xxx1) {
xxx2;
if (xxx3) {
rarely_execute();
xxx4; }
xxx5; }