Options for Basic Block Sections, enabled in D68063 and D73674.
This patch adds clang options:
-fbasic-block-sections={all,<filename>,labels,none} and
-funique-basic-block-section-names.
LLVM Support for basic block sections is already enabled.
+ -fbasic-block-sections={all, <file>, labels, none} : Enables/Disables basic
block sections for all or a subset of basic blocks. "labels" only enables
basic block symbols.
+ -funique-basic-block-section-names: Enables unique section names for
basic block sections, disabled by default.
Differential Revision: https://reviews.llvm.org/D68049
diff --git a/clang/docs/ClangCommandLineReference.rst b/clang/docs/ClangCommandLineReference.rst
index a10e747..4fde603 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -1331,6 +1331,10 @@
.. option:: -fautolink, -fno-autolink
+.. option:: -fbasic-block-sections=labels, -fbasic-block-sections=all, -fbasic-block-sections=list=<arg>, -fbasic-block-sections=none
+
+Generate labels for each basic block or place each basic block or a subset of basic blocks in its own section.
+
.. option:: -fblocks, -fno-blocks
Enable the 'blocks' language feature
diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index ae479e0..d13d418 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1698,6 +1698,44 @@
$ cd $P/bar && clang -c -funique-internal-linkage-names name_conflict.c
$ cd $P && clang foo/name_conflict.o && bar/name_conflict.o
+**-fbasic-block-sections=[labels, all, list=<arg>, none]**
+
+ Controls whether Clang emits a label for each basic block. Further, with
+ values "all" and "list=arg", each basic block or a subset of basic blocks
+ can be placed in its own unique section.
+
+ With the ``list=<arg>`` option, a file containing the subset of basic blocks
+ that need to placed in unique sections can be specified. The format of the
+ file is as follows. For example, ``list=spec.txt`` where ``spec.txt`` is the
+ following:
+
+ ::
+
+ !foo
+ !!2
+ !_Z3barv
+
+ will place the machine basic block with ``id 2`` in function ``foo`` in a
+ unique section. It will also place all basic blocks of functions ``bar``
+ in unique sections.
+
+ Further, section clusters can also be specified using the ``list=<arg>``
+ option. For example, ``list=spec.txt`` where ``spec.txt`` contains:
+
+ ::
+
+ !foo
+ !!1 !!3 !!5
+ !!2 !!4 !!6
+
+ will create two unique sections for function ``foo`` with the first
+ containing the odd numbered basic blocks and the second containing the
+ even numbered basic blocks.
+
+ Basic block sections allow the linker to reorder basic blocks and enables
+ link-time optimizations like whole program inter-procedural basic block
+ reordering.
+
Profile Guided Optimization
---------------------------