Skip to content

Conversation

aleks-tmb
Copy link
Contributor

Reverts #155316

@aleks-tmb aleks-tmb merged commit 70d73b3 into main Aug 28, 2025
9 of 11 checks passed
@aleks-tmb aleks-tmb deleted the revert-155316-apopov/x86-macro-fusion branch August 28, 2025 08:13
@llvmbot
Copy link
Member

llvmbot commented Aug 28, 2025

@llvm/pr-subscribers-backend-x86

Author: Aleksandr Popov (aleks-tmb)

Changes

Reverts llvm/llvm-project#155316


Full diff: https://github.com/llvm/llvm-project/pull/155780.diff

2 Files Affected:

  • (modified) llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp (+1-10)
  • (modified) llvm/test/MC/X86/align-branch-fused.s (+1-19)
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
index 97e50e1ec708a..56a4cc3d65c2e 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -485,16 +485,7 @@ void X86AsmBackend::emitInstructionBegin(MCObjectStreamer &OS,
   if (!CanPadInst)
     return;
 
-  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)
-      return;
-
+  if (PendingBA && PendingBA->getNext() == OS.getCurrentFragment()) {
     // Macro fusion actually happens and there is no other fragment inserted
     // after the previous instruction.
     //
diff --git a/llvm/test/MC/X86/align-branch-fused.s b/llvm/test/MC/X86/align-branch-fused.s
index 5b4a144e30921..7530967a890c6 100644
--- a/llvm/test/MC/X86/align-branch-fused.s
+++ b/llvm/test/MC/X86/align-branch-fused.s
@@ -1,10 +1,7 @@
-# RUN: rm -rf %t && split-file %s %t && cd %t
-# RUN: llvm-mc -filetype=obj -triple x86_64 --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc foo.s | llvm-objdump -d --no-show-raw-insn - | FileCheck foo.s
-# RUN: llvm-mc -filetype=obj -triple x86_64 --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc -x86-pad-max-prefix-size=1 bar.s | llvm-objdump -d --no-show-raw-insn - | FileCheck bar.s
+# RUN: llvm-mc -filetype=obj -triple x86_64 --x86-align-branch-boundary=32 --x86-align-branch=fused+jcc %s | llvm-objdump -d --no-show-raw-insn - | FileCheck %s
 
   # Exercise cases where fused instructions need to be aligned.
 
-#--- foo.s
   .text
   .globl  foo
 foo:
@@ -43,18 +40,3 @@ foo:
   cmp  %rax, %rbp
   jne foo
   int3
-
-# Exercise the case where fused instructions need to be aligned,
-# ensuring fusion is not broken by a NOP
-
-#--- bar.s
-  .text
-	.globl	bar
-bar:
-  .nops 27
-# CHECK:      20:       testq   %rcx, %rcx
-# CHECK:      23:       je
-	testq	%rcx, %rcx
-	je	.EXIT
-.EXIT:
-	ret

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants