Microcode update for Jump Conditional Code Erratum may cause performance
loss for some workloads:
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.