Skip to content

Commit

Permalink
Merged main:a048ce13e32d into amd-gfx:32c39fafa202
Browse files Browse the repository at this point in the history
Local branch amd-gfx 32c39fa Merged main:5238e7b302ff into amd-gfx:7da10bfe5304
Remote branch main a048ce1 [X86] Default to -x86-pad-for-align=false to drop assembler difference with or w/o -g
  • Loading branch information
Sw authored and Sw committed Jan 17, 2021
2 parents 32c39fa + a048ce1 commit f2a7e47
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion llvm/include/llvm/Config/llvm-config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/* Indicate that this is LLVM compiled from the amd-gfx branch. */
#define LLVM_HAVE_BRANCH_AMD_GFX
#define LLVM_MAIN_REVISION 377222
#define LLVM_MAIN_REVISION 377223

/* Define if LLVM_ENABLE_DUMP is enabled */
#cmakedefine LLVM_ENABLE_DUMP
Expand Down
5 changes: 4 additions & 1 deletion llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ cl::opt<unsigned> X86PadMaxPrefixSize(
cl::desc("Maximum number of prefixes to use for padding"));

cl::opt<bool> X86PadForAlign(
"x86-pad-for-align", cl::init(true), cl::Hidden,
"x86-pad-for-align", cl::init(false), cl::Hidden,
cl::desc("Pad previous instructions to implement align directives"));

cl::opt<bool> X86PadForBranchAlign(
Expand Down Expand Up @@ -957,6 +957,9 @@ void X86AsmBackend::finishLayout(MCAssembler const &Asm,
if (!X86PadForAlign && !X86PadForBranchAlign)
return;

// The processed regions are delimitered by LabeledFragments. -g may have more
// MCSymbols and therefore different relaxation results. X86PadForAlign is
// disabled by default to eliminate the -g vs non -g difference.
DenseSet<MCFragment *> LabeledFragments;
for (const MCSymbol &S : Asm.symbols())
LabeledFragments.insert(S.getFragment(false));
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/X86/align-via-padding-corner.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llvm-mc -mcpu=skylake -filetype=obj -triple x86_64-pc-linux-gnu %s -x86-pad-max-prefix-size=5 | llvm-objdump -d - | FileCheck %s
# RUN: llvm-mc -mcpu=skylake -filetype=obj -triple x86_64-pc-linux-gnu %s -x86-pad-max-prefix-size=5 -x86-pad-for-align=1 | llvm-objdump -d - | FileCheck %s


# The first test check the correctness cornercase - can't add prefixes on a
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/X86/align-via-padding.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llvm-mc -mcpu=skylake -filetype=obj -triple x86_64-pc-linux-gnu %s -x86-pad-max-prefix-size=5 | llvm-objdump -d --section=.text - | FileCheck %s
# RUN: llvm-mc -mcpu=skylake -filetype=obj -triple x86_64-pc-linux-gnu %s -x86-pad-max-prefix-size=5 -x86-pad-for-align=1 | llvm-objdump -d - | FileCheck %s

# This test file highlights the interactions between prefix padding and
# relaxation padding.
Expand Down
16 changes: 15 additions & 1 deletion llvm/test/MC/X86/align-via-relaxation.s
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
# RUN: llvm-mc -mcpu=skylake -filetype=obj -triple x86_64-pc-linux-gnu -x86-pad-max-prefix-size=0 %s | llvm-objdump -d --section=.text - | FileCheck %s
# RUN: llvm-mc -mcpu=skylake -filetype=obj -triple x86_64-pc-linux-gnu -x86-pad-max-prefix-size=0 %s | llvm-objdump -d - | FileCheck %s --check-prefix=NOPAD
# RUN: llvm-mc -mcpu=skylake -filetype=obj -triple x86_64-pc-linux-gnu -x86-pad-max-prefix-size=0 -x86-pad-for-align=1 %s | llvm-objdump -d - | FileCheck %s

# This test exercises only the padding via relaxation logic. The interaction
# etween prefix padding and relaxation logic can be seen in align-via-padding.s

.file "test.c"
.text
.section .text

# NOPAD-LABEL: <.text>:
# NOPAD-NEXT: 0: eb 1f jmp 0x21 <foo>
# NOPAD-NEXT: 2: eb 1d jmp 0x21 <foo>
# NOPAD-NEXT: 4: eb 1b jmp 0x21 <foo>
# NOPAD-NEXT: 6: eb 19 jmp 0x21 <foo>
# NOPAD-NEXT: 8: eb 17 jmp 0x21 <foo>
# NOPAD-NEXT: a: eb 15 jmp 0x21 <foo>
# NOPAD-NEXT: c: eb 13 jmp 0x21 <foo>
# NOPAD-NEXT: e: 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 nopw %cs:(%rax,%rax)
# NOPAD-NEXT: 1d: 0f 1f 00 nopl (%rax)
# NOPAD-NEXT: 20: cc int3

# Demonstrate that we can relax instructions to provide padding, not
# just insert nops. jmps are being used for ease of demonstration.
# CHECK: .text
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/X86/prefix-padding-32.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llvm-mc -filetype=obj -triple i386-pc-linux-gnu %s -x86-pad-max-prefix-size=15 | llvm-objdump -d --section=.text - | FileCheck %s
# RUN: llvm-mc -filetype=obj -triple i386-pc-linux-gnu %s -x86-pad-max-prefix-size=15 -x86-pad-for-align=1 | llvm-objdump -d - | FileCheck %s

# Check prefix padding generation for all cases on 32 bit x86.

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/X86/prefix-padding-64.s
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llvm-mc -mcpu=skylake -filetype=obj -triple x86_64-pc-linux-gnu %s -x86-pad-max-prefix-size=15 | llvm-objdump -d --section=.text - | FileCheck %s
# RUN: llvm-mc -mcpu=skylake -filetype=obj -triple x86_64-pc-linux-gnu %s -x86-pad-max-prefix-size=15 -x86-pad-for-align=1 | llvm-objdump -d - | FileCheck %s

# Check prefix padding generation for all cases on 64 bit x86.

Expand Down

0 comments on commit f2a7e47

Please sign in to comment.