Microcode update for Jump Conditional Code Erratum may cause performance
loss for some workloads:
https://www.intel.com/content/www/us/en/support/articles/000055650.html
Here is the patch to mitigate performance impact by aligning branches
within 32-byte boundary. The impacted instructions are:
a. Conditional jump. b. Fused conditional jump. c. Unconditional jump. d. Indirect jump. e. Ret. f. Call.
Add two options for llvm-mc:
- -x86-align-branch-boundary=NUM aligns branches within NUM byte boundary.
- -x86-align-branch=TYPE[+TYPE...] specifies types of branches to align.
to align branches within a 32-Byte boundary to reduce the potential performance
loss of the microcode update.
A new MCFragment type, MCBoundaryAlignFragment, is added, which may emit
NOP to align the fused/unfused branch.
alignBranchesBegin inserts MCBoundaryAlignFragment before instructions,
alignBranchesEnd marks the end of the branch to be aligned,
relaxBoundaryAlign grows or shrinks sizes of NOP to align the target branch.
Nop padding is disabled when the instruction may be rewritten by the linker,
such as TLS Call.
Please add a note that the size is lazily set during relaxation, and is not meaningful before that.