[PATCH] [MC] When using bundle aligment, align sections to bundle size
Derek Schuff
dschuff at google.com
Mon Apr 20 15:44:11 PDT 2015
Hi eliben, jvoung,
Bundle aligment requires that the functions always start at an aligned address.
Usually this is ensured by the compiler, but assembly code does not always
begin with a .align directive.
This change ensures that sections get the correct alignment if they contain
any instructions and bundling is enabled. (It also makes LLVM match the
behavior of GNU as).
http://reviews.llvm.org/D9131
Files:
lib/MC/MCELFStreamer.cpp
Index: lib/MC/MCELFStreamer.cpp
===================================================================
--- lib/MC/MCELFStreamer.cpp
+++ lib/MC/MCELFStreamer.cpp
@@ -131,13 +131,22 @@
llvm_unreachable("invalid assembler flag!");
}
+static void SetSectionAlignmentForBundling(
+ const MCAssembler &Assembler, MCSectionData *Section) {
+ if (Assembler.isBundlingEnabled() && Section &&
+ Section->hasInstructions() &&
+ Section->getAlignment() < Assembler.getBundleAlignSize())
+ Section->setAlignment(Assembler.getBundleAlignSize());
+}
+
void MCELFStreamer::ChangeSection(const MCSection *Section,
const MCExpr *Subsection) {
MCSectionData *CurSection = getCurrentSectionData();
if (CurSection && CurSection->isBundleLocked())
report_fatal_error("Unterminated .bundle_lock when changing a section");
MCAssembler &Asm = getAssembler();
+ SetSectionAlignmentForBundling(Asm, CurSection);
auto *SectionELF = static_cast<const MCSectionELF *>(Section);
const MCSymbol *Grp = SectionELF->getGroup();
if (Grp)
@@ -639,6 +648,8 @@
}
void MCELFStreamer::FinishImpl() {
+ SetSectionAlignmentForBundling(getAssembler(), getCurrentSectionData());
+
EmitFrames(nullptr);
Flush();
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9131.24069.patch
Type: text/x-patch
Size: 1262 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150420/9e10d773/attachment.bin>
More information about the llvm-commits
mailing list