Influence of the performance of the hot and built-in combination to determine the function

I have a function that performs just a few operations, such as increments. I stated that both inline and with __attribute__((hot)) .

Gcc Doc offers the following for the hot attribute:

The hot attribute is used to inform the compiler that the function is the hot spot of the compiled program. The function is optimized more aggressively and for many purposes is placed in a special subsection of the text section, so all the hot functions are close to each other improving the location.

which can be interpreted as for non-t20> hot functions, they will be placed in the lower address area of โ€‹โ€‹the process address card. But inline function calls are supposed to be literally replaced by their code. So the question is, how does the inline and hot combination work?

+6
source share
1 answer

See When should I write the keyword 'inline' for a function / method? for a pretty good explanation of the inline . It seems a contradiction to declare a function as hot and inline ; if a function is not defined in the header file or is not defined in several compilation units, you should not declare it as inline .

In fact, the decision to replace a function call with a function definition and put it โ€œin a stringโ€ depends on the compiler. Thus, the combination of inline and hot most likely ignores the inline part and places it in the text.hot section of the program. Linker is the only part of the process that really cares about the inline , and then it doesn't necessarily do what you can imagine.

+1
source

Source: https://habr.com/ru/post/917917/


All Articles