[PATCH] D77971: [MC][X86][NFC] Disable branch align in non-text section

Kan Shengchen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 12 06:55:59 PDT 2020


skan created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
skan edited the summary of this revision.
skan added reviewers: MaskRay, reames, LuoYuanke.

It's quite NFC to me, but I'd like to hear others's opinions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77971

Files:
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/test/MC/X86/align-branch-section-size.s
  llvm/test/MC/X86/align-branch-section-type.s


Index: llvm/test/MC/X86/align-branch-section-type.s
===================================================================
--- llvm/test/MC/X86/align-branch-section-type.s
+++ llvm/test/MC/X86/align-branch-section-type.s
@@ -1,20 +1,18 @@
 # RUN: llvm-mc -filetype=obj -triple x86_64 --x86-align-branch-boundary=32 --x86-align-branch=ret %s | llvm-readobj -S | FileCheck %s
 
-  # Check the aligment of section that contains instructions to be aligned
-  # is correctly set.
+  # Check we only pad in a text section
 
-  # CHECK:  Name: text1
+  # CHECK:  Name: text
   # CHECK:  AddressAlignment: 32
-  .section text1
-foo:
+  .section text, "ax"
   ret
 
-  # CHECK:  Name: text2
+  # CHECK:  Name: excluded
   # CHECK:  AddressAlignment: 1
-  .section text2
-  nop
+  .section excluded, "e"
+  ret
 
-  # CHECK:  Name: text3
+  # CHECK:  Name: tls
   # CHECK:  AddressAlignment: 1
-  .section text3
-  jmp foo
+  .section tls, "awT"
+  ret
Index: llvm/test/MC/X86/align-branch-section-size.s
===================================================================
--- llvm/test/MC/X86/align-branch-section-size.s
+++ llvm/test/MC/X86/align-branch-section-size.s
@@ -5,16 +5,16 @@
 
   # CHECK:  Name: text1
   # CHECK:  AddressAlignment: 32
-  .section text1
+  .section text1, "ax"
 foo:
   ret
 
   # CHECK:  Name: text2
   # CHECK:  AddressAlignment: 1
-  .section text2
+  .section text2, "ax"
   nop
 
   # CHECK:  Name: text3
   # CHECK:  AddressAlignment: 1
-  .section text3
+  .section text3, "ax"
   jmp foo
Index: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
===================================================================
--- llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -566,6 +566,10 @@
     return false;
   assert(allowAutoPadding() && "incorrect initialization!");
 
+  // We only pad in text section.
+  if (!OS.getCurrentSectionOnly()->getKind().isText())
+    return false;
+
   // To be Done: Currently don't deal with Bundle cases.
   if (OS.getAssembler().isBundlingEnabled())
     return false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77971.256850.patch
Type: text/x-patch
Size: 2089 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200412/93cd7310/attachment.bin>


More information about the llvm-commits mailing list