Clang FE currently has hot/cold function attribute. But we only have cold
function attribute in LLVM IR.
This patch adds support of hot function attribute to LLVM IR.
This attribute will be used in setting function section prefix/suffix.
Currently .hot and .unlikely suffix only are added in PGO (Sample PGO)
compilation (through isFunctionHotInCallGraph and isFunctionColdInCallGraph).
This patch changes the behavior. The new behavior is:
(1) If the user annotates a function as hot or isFunctionHotInCallGraph
is true, this function will be marked as hot.
(2) If the user annotates a function as cold or isFunctionColdInCallGraph
is true, this function will be marked as cold.
The changes are:
(1) user annotated function will used in setting function section prefix/suffix.
(2) hot attribute overwrites profile count based hotness.
(3) profile count based hotness overwrite user annotated cold attribute.
The intention for these changes is to provide the user a way to mark
certain function as hot in cases where training input is hard to cover all
the hot functions.
One thing that we might also need to change is we set cold attribute
in PGO instrumentation. This code is before isFunctionColdInCallGraph and
not use PSI. With this patch, we may mark more cold functions.
I did not change this part because cold attribute is used many downstream
optimizations other than setting function section prefix/suffix.
Omit braces
https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements