[all-commits] [llvm/llvm-project] abfe55: MC: Fix NOP insertion between fused instructions t...

Aleksandr Popov via All-commits all-commits at lists.llvm.org
Thu Aug 28 02:04:02 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: abfe556c46f7c055cacc79f3aa322bb2c05d92f5
      https://github.com/llvm/llvm-project/commit/abfe556c46f7c055cacc79f3aa322bb2c05d92f5
  Author: Aleksandr Popov <42888396+aleks-tmb at users.noreply.github.com>
  Date:   2025-08-28 (Thu, 28 Aug 2025)

  Changed paths:
    M llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
    M llvm/test/MC/X86/align-branch-fused.s

  Log Message:
  -----------
  MC: Fix NOP insertion between fused instructions that breaks macro fusion (#155784)

In the
https://github.com/llvm/llvm-project/commit/39c8cfb70d203439e3296dfdfe3d41f1cb2ec551
patch, getOrCreateDataFragment was optimized by eagerly allocating an
empty fragment when adding a fragment with a variable-size tail. This
means that in this case the current MC fragment is no longer the one
where the instruction was inserted, and the check
`PendingBA && PendingBA->getNext() == OS.getCurrentFragment()` fails,
since CurrentFragment is now the empty fragment instead of the fragment
containing the instruction.

`PendingBA -> Fragment with a variable-size tail (contains previous
instruction) -> CurrentFragment (newly allocated empty fragment)`

This breaks the macro-fusion logic because it incorrectly assumes
another fragment has been inserted between the fused instructions.

Fixes https://github.com/llvm/llvm-project/issues/155045

#155316 Reland



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