Skip to content

Commit 70d73b3

Browse files
authored
Revert "[X86] Fix incorrect NOP insertion between fused instructions that breaks macro fusion" (#155780)
Reverts #155316
1 parent 1683083 commit 70d73b3

File tree

2 files changed

+2
-29
lines changed

2 files changed

+2
-29
lines changed

llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -485,16 +485,7 @@ void X86AsmBackend::emitInstructionBegin(MCObjectStreamer &OS,
485485
if (!CanPadInst)
486486
return;
487487

488-
if (PendingBA) {
489-
auto *NextFragment = PendingBA->getNext();
490-
assert(NextFragment && "NextFragment should not be null");
491-
if (NextFragment == OS.getCurrentFragment())
492-
return;
493-
// We eagerly create an empty fragment when inserting a fragment
494-
// with a variable-size tail.
495-
if (NextFragment->getKind() == MCFragment::FT_Relaxable)
496-
return;
497-
488+
if (PendingBA && PendingBA->getNext() == OS.getCurrentFragment()) {
498489
// Macro fusion actually happens and there is no other fragment inserted
499490
// after the previous instruction.
500491
//

llvm/test/MC/X86/align-branch-fused.s

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
# RUN: rm -rf %t && split-file %s %t && cd %t
2-
# 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
3-
# 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
1+
# 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
42

53
# Exercise cases where fused instructions need to be aligned.
64

7-
#--- foo.s
85
.text
96
.globl foo
107
foo:
@@ -43,18 +40,3 @@ foo:
4340
cmp %rax, %rbp
4441
jne foo
4542
int3
46-
47-
# Exercise the case where fused instructions need to be aligned,
48-
# ensuring fusion is not broken by a NOP
49-
50-
#--- bar.s
51-
.text
52-
.globl bar
53-
bar:
54-
.nops 27
55-
# CHECK: 20: testq %rcx, %rcx
56-
# CHECK: 23: je
57-
testq %rcx, %rcx
58-
je .EXIT
59-
.EXIT:
60-
ret

0 commit comments

Comments
 (0)