[BOLT] Generate sections for multiple fragments
authorFabian Parzefall <parzefall@fb.com>
Fri, 19 Aug 2022 04:48:19 +0000 (21:48 -0700)
committerFabian Parzefall <parzefall@fb.com>
Fri, 19 Aug 2022 04:55:06 +0000 (21:55 -0700)
commit0f74d191d12e1807d291c8db937f1bb89cfe7caa
treeeca1aa3564fe3ef97f4d0df70584f53e3c21a623
parenta191ea7d59508b19a0e73d9a23adc768bcc98246
[BOLT] Generate sections for multiple fragments

This patch adds support to generate any number of sections that are
assigned to fragments of functions that are split more than two-way.
With this, a function's *nth* split fragment goes into section
`.text.cold.n`.

This also changes `FunctionLayout::erase` to make sure, that there are
no empty fragments at the end of the function. This sometimes happens
when blocks are erased from the function. To avoid creating symbols
pointing to these fragments, they need to be removed.

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D130521
bolt/include/bolt/Core/BinaryBasicBlock.h
bolt/include/bolt/Core/BinaryFunction.h
bolt/include/bolt/Core/FunctionLayout.h
bolt/lib/Core/BinaryContext.cpp
bolt/lib/Core/BinaryEmitter.cpp
bolt/lib/Core/BinaryFunction.cpp
bolt/lib/Core/FunctionLayout.cpp
bolt/lib/Passes/SplitFunctions.cpp
bolt/lib/Rewrite/RewriteInstance.cpp