[PATCH] D77971: [MC][X86] Disable branch align in non-text section
Kan Shengchen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 16 00:47:48 PDT 2020
skan updated this revision to Diff 257973.
skan added a comment.
Address review comments
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.257973.patch
Type: text/x-patch
Size: 1262 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200416/d9e11e3a/attachment.bin>
More information about the llvm-commits
mailing list