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

Kan Shengchen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 17 23:58:05 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG0d3149f43173: [MC][X86] Disable branch align in non-text section (authored by skan).

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-LABEL:  Name: text
+# CHECK:        AddressAlignment: 32
+.section text, "ax"
+ret
+
+# CHECK-LABEL:  Name: excluded
+# CHECK:        AddressAlignment: 1
+.section excluded, "e"
+ret
+
+# CHECK-LABEL:  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.258487.patch
Type: text/x-patch
Size: 1238 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200418/f64c7ff3/attachment.bin>


More information about the llvm-commits mailing list