diff options
author | Derek Schuff <dschuff@google.com> | 2013-02-05 17:55:27 +0000 |
---|---|---|
committer | Derek Schuff <dschuff@google.com> | 2013-02-05 17:55:27 +0000 |
commit | 90aa1d8abeff8269efcdcbe1f70658387e29e625 (patch) | |
tree | 0659f404d0dfaeba86d4fdde03122fd947a73081 /llvm/lib/MC/MCAssembler.cpp | |
parent | fdc37670f64615d2d84d3beddee074d7d8151b96 (diff) | |
download | bcm5719-llvm-90aa1d8abeff8269efcdcbe1f70658387e29e625.tar.gz bcm5719-llvm-90aa1d8abeff8269efcdcbe1f70658387e29e625.zip |
[MC] Bundle alignment: Invalidate relaxed fragments
Currently, when a fragment is relaxed, its size is modified, but its
offset is not (it gets laid out as a side effect of checking whether
it needs relaxation), then all subsequent fragments are invalidated
because their offsets need to change. When bundling is enabled,
relaxed fragments need to get laid out again, because the increase in
size may push it over a bundle boundary. So instead of only
invalidating subsequent fragments, also invalidate the fragment that
gets relaxed, which causes it to get laid out again.
This patch also fixes some trailing whitespace and fixes the
bundling-related debug output of MCFragments.
llvm-svn: 174401
Diffstat (limited to 'llvm/lib/MC/MCAssembler.cpp')
-rw-r--r-- | llvm/lib/MC/MCAssembler.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp index 498fbf77ad5..fd281e67c78 100644 --- a/llvm/lib/MC/MCAssembler.cpp +++ b/llvm/lib/MC/MCAssembler.cpp @@ -82,14 +82,15 @@ 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. + // Otherwise, reset the last valid fragment to the previous fragment + // (if this is the first fragment, it will be NULL). 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 @@ -939,7 +940,7 @@ bool MCAssembler::layoutSectionOnce(MCAsmLayout &Layout, MCSectionData &SD) { FirstRelaxedFragment = I; } if (FirstRelaxedFragment) { - Layout.invalidateFragmentsAfter(FirstRelaxedFragment); + Layout.invalidateFragmentsFrom(FirstRelaxedFragment); return true; } return false; @@ -999,7 +1000,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: { |