diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2010-05-17 21:54:30 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2010-05-17 21:54:30 +0000 |
| commit | aa22938518196a232c110f557c10dbaf86bddd24 (patch) | |
| tree | bd0033f43606e67c72103041a84fb5d2b9851ba0 /lib/MC/MCParser | |
| parent | c10d5039833a1cc9e1305a73e65b63329c9104ea (diff) | |
| download | external_llvm-aa22938518196a232c110f557c10dbaf86bddd24.zip external_llvm-aa22938518196a232c110f557c10dbaf86bddd24.tar.gz external_llvm-aa22938518196a232c110f557c10dbaf86bddd24.tar.bz2 | |
MC/Mach-O/x86: Optimal nop sequences should only be used for the .text sections, not all sections in the text segment.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103981 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCParser')
| -rw-r--r-- | lib/MC/MCParser/AsmParser.cpp | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 0df839b..c491673 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -1178,10 +1178,8 @@ bool AsmParser::ParseDirectiveAlign(bool IsPow2, unsigned ValueSize) { Lex(); - if (!HasFillExpr) { - // FIXME: Sometimes fill with nop. + if (!HasFillExpr) FillExpr = 0; - } // Compute alignment in bytes. if (IsPow2) { @@ -1209,14 +1207,21 @@ bool AsmParser::ParseDirectiveAlign(bool IsPow2, unsigned ValueSize) { } } - // FIXME: hard code the parser to use EmitCodeAlignment for text when using - // the TextAlignFillValue. - if(Out.getCurrentSection()->getKind().isText() && - Lexer.getMAI().getTextAlignFillValue() == FillExpr) + // Check whether we should use optimal code alignment for this .align + // directive. + // + // FIXME: This should be using a target hook. + bool UseCodeAlign = false; + if (const MCSectionMachO *S = dyn_cast<MCSectionMachO>( + Out.getCurrentSection())) + UseCodeAlign = S->hasAttribute(MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS); + if ((!HasFillExpr || Lexer.getMAI().getTextAlignFillValue() == FillExpr) && + ValueSize == 1 && UseCodeAlign) { Out.EmitCodeAlignment(Alignment, MaxBytesToFill); - else + } else { // FIXME: Target specific behavior about how the "extra" bytes are filled. Out.EmitValueToAlignment(Alignment, FillExpr, ValueSize, MaxBytesToFill); + } return false; } |
