aboutsummaryrefslogtreecommitdiff
path: root/lib/MC/MCAssembler.cpp
diff options
context:
space:
mode:
authorDerek Schuff <dschuff@chromium.org>2013-02-04 10:43:45 -0800
committerDerek Schuff <dschuff@chromium.org>2013-02-04 10:43:45 -0800
commit80abe0746cec97dd07ba74db157e85f6e83487a2 (patch)
tree3edb499ed31c708a87ec25f56d6918701d91c8e3 /lib/MC/MCAssembler.cpp
parent3d5de9e56f3e5af59772bdf2cbedb0903d938bb8 (diff)
Cherry-pick not-yet-committed upstream change to fix relaxation at bundle end
Diffstat (limited to 'lib/MC/MCAssembler.cpp')
-rw-r--r--lib/MC/MCAssembler.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp
index e5d4995e16..0b572eeca8 100644
--- a/lib/MC/MCAssembler.cpp
+++ b/lib/MC/MCAssembler.cpp
@@ -18,6 +18,7 @@
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCDwarf.h"
#include "llvm/MC/MCExpr.h"
+#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCFixupKindInfo.h"
#include "llvm/MC/MCObjectWriter.h"
#include "llvm/MC/MCSection.h"
@@ -82,14 +83,14 @@ bool MCAsmLayout::isFragmentValid(const MCFragment *F) const {
return F->getLayoutOrder() <= LastValid->getLayoutOrder();
}
-void MCAsmLayout::invalidateFragmentsAfter(MCFragment *F) {
+void MCAsmLayout::invalidateFragmentsFrom(MCFragment *F) {
// If this fragment wasn't already valid, we don't need to do anything.
if (!isFragmentValid(F))
return;
// Otherwise, reset the last valid fragment to this fragment.
const MCSectionData &SD = *F->getParent();
- LastValidFragment[&SD] = F;
+ LastValidFragment[&SD] = F->getPrevNode();
}
void MCAsmLayout::ensureValid(const MCFragment *F) const {
@@ -165,14 +166,14 @@ uint64_t MCAsmLayout::getSectionFileSize(const MCSectionData *SD) const {
uint64_t MCAsmLayout::computeBundlePadding(const MCFragment *F,
uint64_t FOffset, uint64_t FSize) {
uint64_t BundleSize = Assembler.getBundleAlignSize();
- assert(BundleSize > 0 &&
+ assert(BundleSize > 0 &&
"computeBundlePadding should only be called if bundling is enabled");
uint64_t BundleMask = BundleSize - 1;
uint64_t OffsetInBundle = FOffset & BundleMask;
uint64_t EndOfFragment = OffsetInBundle + FSize;
// There are two kinds of bundling restrictions:
- //
+ //
// 1) For alignToBundleEnd(), add padding to ensure that the fragment will
// *end* on a bundle boundary.
// 2) Otherwise, check if the fragment would cross a bundle boundary. If it
@@ -238,8 +239,14 @@ MCSectionData::MCSectionData(const MCSection &_Section, MCAssembler *A)
BundleLockState(NotBundleLocked), BundleGroupBeforeFirstInst(false),
HasInstructions(false)
{
- if (A)
+ // @LOCALMOD-BEGIN
+ if (A) {
+ // TODO(dschuff): Carryover from previous localmods. still necessary?
A->getSectionList().push_back(this);
+ if (A->isBundlingEnabled() && _Section.UseCodeAlign())
+ setAlignment(A->getBundleAlignSize());
+ }
+ // @LOCALMOD-END
}
/* *** */
@@ -938,7 +945,7 @@ bool MCAssembler::layoutSectionOnce(MCAsmLayout &Layout, MCSectionData &SD) {
FirstRelaxedFragment = I;
}
if (FirstRelaxedFragment) {
- Layout.invalidateFragmentsAfter(FirstRelaxedFragment);
+ Layout.invalidateFragmentsFrom(FirstRelaxedFragment);
return true;
}
return false;
@@ -998,7 +1005,7 @@ void MCFragment::dump() {
OS << "<MCFragment " << (void*) this << " LayoutOrder:" << LayoutOrder
<< " Offset:" << Offset
<< " HasInstructions:" << hasInstructions()
- << " BundlePadding:" << getBundlePadding() << ">";
+ << " BundlePadding:" << static_cast<unsigned>(getBundlePadding()) << ">";
switch (getKind()) {
case MCFragment::FT_Align: {