[llvm] [llvm][ctx_profile] Add the `llvm.instrprof.callsite` intrinsic (PR #89939)

Snehasish Kumar via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 25 09:17:17 PDT 2024


================
@@ -14139,6 +14139,37 @@ Semantics:
 """"""""""
 See description of '``llvm.instrprof.increment``' intrinsic.
 
+'``llvm.instrprof.callsite``' Intrinsic
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Syntax:
+"""""""
+
+::
+
+      declare void @llvm.instrprof.callsite(ptr <name>, i64 <hash>,
+                                            i32 <num-counters>,
+                                            i32 <index>, ptr <callsite>)
+
+Overview:
+"""""""""
+
+The '``llvm.instrprof.callsite``' intrinsic should be emitted before a callsite
+that's not to a "fake" callee (like another intrinsic or asm). 
+
+Arguments:
+""""""""""
+The first 3 arguments are similar to ``llvm.instrprof.increment``. The indexing
+is specific to callsites, meaning callsites are indexed from 0, independent from
+the indexes used by the other intrinsics (such as 
+``llvm.instrprof.increment[.step]``).
+
+The last argument is the called value of the callsite this intrinsic precedes.
+
+Semantics:
+""""""""""
+This is lowered by contextual profiling.
----------------
snehasish wrote:

Can you expand this a bit to spell out how it is used (apart from just mentioning contextual profiling) like how it should be lowered, does it modify program behaviour, should it be treated as immovable by optimizations, when it should be ignored by backends and so on?

https://github.com/llvm/llvm-project/pull/89939


More information about the llvm-commits mailing list