[llvm] [X86] Fix incorrect NOP insertion between fused instructions that breaks macro fusion (PR #155316)
Aleksandr Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 27 02:15:11 PDT 2025
================
@@ -520,7 +520,19 @@ void X86AsmBackend::emitInstructionBegin(MCObjectStreamer &OS,
if (!canPadInst(Inst, OS))
return;
- if (PendingBA && PendingBA->getNext() == OS.getCurrentFragment()) {
+ if (PendingBA) {
+ auto *NextFragment = PendingBA->getNext();
+ assert(NextFragment && "NextFragment should not be null");
+
+ if (NextFragment == OS.getCurrentFragment())
+ return;
+
+ // We eagerly create an empty fragment when inserting a fragment
+ // with a variable-size tail.
+ if (NextFragment->getKind() == MCFragment::FT_Relaxable &&
----------------
aleks-tmb wrote:
So, it’s a conservative check, since I haven’t verified whether it can be applied to all fragment types. I might relax the check in a follow-up patch.
https://github.com/llvm/llvm-project/pull/155316
More information about the llvm-commits
mailing list