[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
Wed Apr 15 01:36:09 PDT 2020


skan updated this revision to Diff 257621.
skan edited the summary of this revision.
skan added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77971/new/

https://reviews.llvm.org/D77971

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


Index: llvm/test/MC/X86/align-branch-section-type.s
===================================================================
--- /dev/null
+++ llvm/test/MC/X86/align-branch-section-type.s
@@ -0,0 +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 we only pad in a text section
+
+  # CHECK:  Name: text
+  # CHECK:  AddressAlignment: 32
+  .section text, "ax"
+  ret
+
+  # CHECK:  Name: excluded
+  # CHECK:  AddressAlignment: 1
+  .section excluded, "e"
+  ret
+
+  # CHECK:  Name: tls
+  # CHECK:  AddressAlignment: 1
+  .section tls, "awT"
+  ret
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.257621.patch
Type: text/x-patch
Size: 1227 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200415/fb4fcc24/attachment.bin>


More information about the llvm-commits mailing list