[PATCH] D76285: [X86][MC] Fix the bug for prefix padding support

Kan Shengchen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 17 07:57:51 PDT 2020


skan created this revision.
skan added reviewers: reames, MaskRay, craig.topper, LuoYuanke, jyknight.
Herald added a project: LLVM.

There is a tiny logic error of D75300 <https://reviews.llvm.org/D75300>, making branch is not
correctly aligned with option -x86-pad-max-prefix-size


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76285

Files:
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/test/MC/X86/align-branch-64-pad-max-prefix.s


Index: llvm/test/MC/X86/align-branch-64-pad-max-prefix.s
===================================================================
--- /dev/null
+++ llvm/test/MC/X86/align-branch-64-pad-max-prefix.s
@@ -0,0 +1,18 @@
+  # RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu --x86-align-branch-boundary=32 --x86-align-branch=jmp -x86-pad-max-prefix-size=5 %s | llvm-objdump -d --no-show-raw-insn - | FileCheck %s
+  # Check instructions can be aligned correctly along with option -x86-pad-max-prefix-size=5
+
+  .text
+  .p2align 5
+  .rept 24
+  int3
+  .endr
+  # We should not increase the length of this jmp to reduce the bytes of
+  # following nops, doing so would make the jmp misaligned.
+# CHECK:      18:          jmp
+  jmp bar
+# CHECK:      1d:          nop
+# CHECK:      1e:          nop
+# CHECK:      1f:          nop
+# CHECK:      20:          int3
+  .p2align 5
+  int3
Index: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
===================================================================
--- llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -970,10 +970,6 @@
       const uint64_t OrigOffset = Layout.getFragmentOffset(&F);
 #endif
       const uint64_t OrigSize = Asm.computeFragmentSize(Layout, F);
-      if (OrigSize == 0 || Relaxable.empty()) {
-        Relaxable.clear();
-        continue;
-      }
 
       // To keep the effects local, prefer to relax instructions closest to
       // the align directive.  This is purely about human understandability


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76285.250773.patch
Type: text/x-patch
Size: 1545 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200317/5f77f2e9/attachment.bin>


More information about the llvm-commits mailing list