[llvm] [BasicBlockSections] Introduce the path cloning profile format to BasicBlockSectionsProfileReader. (PR #67214)

Sriraman Tallam via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 11 15:29:13 PDT 2023


================
@@ -61,8 +81,45 @@ BasicBlockSectionsProfileReader::getBBClusterInfoForFunction(
 // aliases. Basic block clusters are specified by 'c' and specify the cluster of
 // basic blocks, and the internal order in which they must be placed in the same
 // section.
+// This profile can also specify cloning paths which instruct the compiler to
+// clone basic blocks along a path. The cloned blocks are then specified in the
+// cluster information.
+// The following profile lists two cloning paths (starting with 'p') for
+// function bar and places the total 9 blocks within two clusters. Each cloned
+// block is identified by its original block id, along with its clone id. A
+// block cloned multiple times appears with distinct clone ids. The CFG for bar
+// is shown below before and after cloning with final clusters labeled.
+//
+// f main
+// f bar
+// p 1 3 4
+// p 4 2
+// c 1 3.1 4.1 6
+// c 0 2 3 4 2.1 5
+// ****************************************************************************
+// function bar before and after cloning with basic block clusters shown.
+// ****************************************************************************
+//                                ....      ..............
+//      0 -------+                : 0 :---->: 1 ---> 3.1 :
+//      |        |                : | :     :........ |  :
+//      v        v                : v :             : v  :
+// +--> 2 --> 5  1     ~~~~~~~>   : 2 :             : 4.1: clsuter 1
+// |    |        |                : | :             : |  :
+// |    v        |                : v .......       : v  :
+// |    3 <------+                : 3 <--+  :       : 6  :
+// |    |                         : |    |  :       :....:
----------------
tmsri wrote:

Also, it is not clear to me what would constitute a valid cloning definition?  For example, let's take the one you mentioned:

c 0 2 3 4 2.1 5

Can this be more compactly represented as:

c 2 3 4 2.1 5

or even more compactly as 
 
c 4 2.1

Why would these more compact representations be wrong?





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


More information about the llvm-commits mailing list