@@ -5192,6 +5192,72 @@ Example:
5192
5192
!0 = !{i32* @a}
5193
5193
5194
5194
5195
+ '``prof ``' Metadata
5196
+ ^^^^^^^^^^^^^^^^^^^
5197
+
5198
+ The ``prof `` metadata is used to record profile data in the IR.
5199
+ The first operand of the metadata node indicates the profile metadata
5200
+ type. There are currently 3 types:
5201
+ :ref: `branch_weights<prof_node_branch_weights> `,
5202
+ :ref: `function_entry_count<prof_node_function_entry_count> `, and
5203
+ :ref: `VP<prof_node_VP> `.
5204
+
5205
+ .. _prof_node_branch_weights :
5206
+
5207
+ branch_weights
5208
+ """"""""""""""
5209
+
5210
+ Branch weight metadata attached to a branch, select, switch or call instruction
5211
+ represents the likeliness of the associated branch being taken.
5212
+ For more information, see :doc: `BranchWeightMetadata `.
5213
+
5214
+ .. _prof_node_function_entry_count :
5215
+
5216
+ function_entry_count
5217
+ """"""""""""""""""""
5218
+
5219
+ Function entry count metadata can be attached to function definitions
5220
+ to record the number of times the function is called. Used with BFI
5221
+ information, it is also used to derive the basic block profile count.
5222
+ For more information, see :doc: `BranchWeightMetadata `.
5223
+
5224
+ .. _prof_node_VP :
5225
+
5226
+ VP
5227
+ ""
5228
+
5229
+ VP (value profile) metadata can be attached to instructions that have
5230
+ value profile information. Currently this is indirect calls (where it
5231
+ records the hottest callees) and calls to memory intrinsics such as memcpy,
5232
+ memmove, and memset (where it records the hottest byte lengths).
5233
+
5234
+ Each VP metadata node contains "VP" string, then a uint32_t value for the value
5235
+ profiling kind, a uint64_t value for the total number of times the instruction
5236
+ is executed, followed by uint64_t value and execution count pairs.
5237
+ The value profiling kind is 0 for indirect call targets and 1 for memory
5238
+ operations. For indirect call targets, each profile value is a hash
5239
+ of the callee function name, and for memory operations each value is the
5240
+ byte length.
5241
+
5242
+ Note that the value counts do not need to add up to the total count
5243
+ listed in the third operand (in practice only the top hottest values
5244
+ are tracked and reported).
5245
+
5246
+ Indirect call example:
5247
+
5248
+ .. code-block :: llvm
5249
+
5250
+ call void %f(), !prof !1
5251
+ !1 = !{!"VP", i32 0, i64 1600, i64 7651369219802541373, i64 1030, i64 -4377547752858689819, i64 410}
5252
+
5253
+ Note that the VP type is 0 (the second operand), which indicates this is
5254
+ an indirect call value profile data. The third operand indicates that the
5255
+ indirect call executed 1600 times. The 4th and 6th operands give the
5256
+ hashes of the 2 hottest target functions' names (this is the same hash used
5257
+ to represent function names in the profile database), and the 5th and 7th
5258
+ operands give the execution count that each of the respective prior target
5259
+ functions was called.
5260
+
5195
5261
Module Flags Metadata
5196
5262
=====================
5197
5263
0 commit comments