[all-commits] [llvm/llvm-project] ea222b: [MC] Honour alignment directive fill value for non...

Sam Elliott via All-commits all-commits at lists.llvm.org
Wed Jul 24 10:25:02 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ea222be0d9266d9d5c100496f8c9606f213454ee
      https://github.com/llvm/llvm-project/commit/ea222be0d9266d9d5c100496f8c9606f213454ee
  Author: Sam Elliott <quic_aelliott at quicinc.com>
  Date:   2024-07-24 (Wed, 24 Jul 2024)

  Changed paths:
    M lld/test/COFF/lto-cpu-string.ll
    M lld/test/ELF/lto/cpu-string.ll
    M lld/test/ELF/lto/mllvm.ll
    M lld/test/MachO/lto-cpu-string.ll
    M llvm/docs/ReleaseNotes.rst
    M llvm/lib/MC/MCParser/AsmParser.cpp
    A llvm/test/MC/AArch64/align-fill-byte-zero.s
    A llvm/test/MC/ARM/align-fill-byte-zero.s
    M llvm/test/MC/AsmParser/directive_align.s
    M llvm/test/MC/COFF/align-nops.s
    M llvm/test/MC/ELF/align-nops.s
    M llvm/test/MC/MachO/x86_32-optimal_nop.s
    A llvm/test/MC/RISCV/align-fill-byte-zero.s
    M llvm/test/MC/X86/code16gcc-align.s

  Log Message:
  -----------
  [MC] Honour alignment directive fill value for non-intel (#100136)

As reported in https://llvm.org/PR30955, `.balign` with a fill-value of 0 did
not actually align using zeroes, on non-x86 targets.

This is because the check of whether to use the code alignment routines
or whether to just use the fill value was checking whether the fill
value was equal to `TextAlignFillValue`, which has not been changed from
its default of 0 on most targets (it has been changed for x86). However,
most targets do not set the fill value because it doesn't entirely make
sense -- i.e. on AArch64 there's no reasonable byte value to use for
alignment, as instructions are word-sized and have to be well-aligned.

I think the check at the end `AsmParser::parseDirectiveAlign` is
suspicious even on x86 - if you use `.balign <align>, 0x90` in a code
section, you don't end up with a block of `0x90` repeated, you end up
with a block of NOPs of various widths. This functionality is never
tested.

The fix here is to modify the check to ignore the default text align
fill value when choosing to do code alignment or not.

Fixes #30303



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list