[PATCH] D75268: A light-weight solution to align branches within 32B boundary by prefix padding

Kan Shengchen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 27 08:51:07 PST 2020


skan created this revision.
skan added reviewers: annita.zhang, craig.topper, MaskRay, reames, LuoYuanke, jyknight.
Herald added subscribers: llvm-commits, dexonsmith, hiraditya.
Herald added a project: LLVM.

If we want a branch or a fused pair not to cross or be against the
boundary, we currently emit NOP before it (D70157 <https://reviews.llvm.org/D70157>), and in most cases, we can
bring back the lost performance due to microcode update. We also observed cases
in which nop padding doesn't mitigate the effect very well, but prefix padding
does (D72225 <https://reviews.llvm.org/D72225>). As we discussed about the prefix padding, D72225 <https://reviews.llvm.org/D72225> adopts an
aggressive way to add prefixes and, as a result, the fact that every single
intruction ends up in it's own fragment is a huge increase in memory usage. So
we put forward a light-weight solution. In this solution, to align a branch,
at most one instruction can be prefixed, and if there is no sufficient room to
add segment prefixes, NOP will be inserted instead. We measured the
memory usage of the link process with lto when building SPEC, it only
increased a little compared to NOP padding. We turned on the new prefix
padding by default and passed the internal large test set and llvm's testsuite.

D75203 <https://reviews.llvm.org/D75203> seems to support a general alignment padding. If the general alignment padding supports adding prefixes for instructions, this patch is not needed. Currently, the revison is opened here to avoid duplicate work .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75268

Files:
  llvm/include/llvm/MC/MCFragment.h
  llvm/include/llvm/MC/MCObjectStreamer.h
  llvm/lib/MC/MCAssembler.cpp
  llvm/lib/MC/MCFragment.cpp
  llvm/lib/MC/MCObjectStreamer.cpp
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/test/MC/X86/align-branch-32-1a.s
  llvm/test/MC/X86/align-branch-32-2a.s
  llvm/test/MC/X86/align-branch-32-3a.s
  llvm/test/MC/X86/align-branch-32-4a.s
  llvm/test/MC/X86/align-branch-64-1e.s
  llvm/test/MC/X86/align-branch-64-2d.s
  llvm/test/MC/X86/align-branch-64-7a.s
  llvm/test/MC/X86/align-branch-64-8a.s
  llvm/test/MC/X86/align-branch-64-9a.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75268.246957.patch
Type: text/x-patch
Size: 44635 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200227/beefae05/attachment-0001.bin>


More information about the llvm-commits mailing list