mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-17 06:33:21 +00:00
Invalidate the layout on any relaxation, not just Instructions. Bug found by David Meyer.
While here, remove unused argument and rename UpdateForSlide to Invalidate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120009 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d93ceeb125
commit
a9d4281cc0
@ -54,10 +54,9 @@ public:
|
|||||||
/// Get the assembler object this is a layout for.
|
/// Get the assembler object this is a layout for.
|
||||||
MCAssembler &getAssembler() const { return Assembler; }
|
MCAssembler &getAssembler() const { return Assembler; }
|
||||||
|
|
||||||
/// \brief Update the layout because a fragment has been resized. The
|
/// \brief Invalidate all following fragments because a fragment has been resized. The
|
||||||
/// fragments size should have already been updated, the \arg SlideAmount is
|
/// fragments size should have already been updated.
|
||||||
/// the delta from the old size.
|
void Invalidate(MCFragment *F);
|
||||||
void UpdateForSlide(MCFragment *F, int SlideAmount);
|
|
||||||
|
|
||||||
/// \brief Update the layout, replacing Src with Dst. The contents
|
/// \brief Update the layout, replacing Src with Dst. The contents
|
||||||
/// of Src and Dst are not modified, and must be copied by the caller.
|
/// of Src and Dst are not modified, and must be copied by the caller.
|
||||||
|
@ -78,7 +78,7 @@ bool MCAsmLayout::isFragmentUpToDate(const MCFragment *F) const {
|
|||||||
F->getLayoutOrder() <= LastValidFragment->getLayoutOrder());
|
F->getLayoutOrder() <= LastValidFragment->getLayoutOrder());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmLayout::UpdateForSlide(MCFragment *F, int SlideAmount) {
|
void MCAsmLayout::Invalidate(MCFragment *F) {
|
||||||
// If this fragment wasn't already up-to-date, we don't need to do anything.
|
// If this fragment wasn't already up-to-date, we don't need to do anything.
|
||||||
if (!isFragmentUpToDate(F))
|
if (!isFragmentUpToDate(F))
|
||||||
return;
|
return;
|
||||||
@ -143,7 +143,7 @@ void MCAsmLayout::CoalesceFragments(MCFragment *Src, MCFragment *Dst) {
|
|||||||
Dst->EffectiveSize += Src->EffectiveSize;
|
Dst->EffectiveSize += Src->EffectiveSize;
|
||||||
} else {
|
} else {
|
||||||
// We don't know the effective size of Src, so we have to invalidate Dst.
|
// We don't know the effective size of Src, so we have to invalidate Dst.
|
||||||
UpdateForSlide(Dst, 0);
|
Invalidate(Dst);
|
||||||
}
|
}
|
||||||
// Remove Src, but don't delete it yet.
|
// Remove Src, but don't delete it yet.
|
||||||
Src->getParent()->getFragmentList().remove(Src);
|
Src->getParent()->getFragmentList().remove(Src);
|
||||||
@ -819,7 +819,6 @@ bool MCAssembler::RelaxInstruction(const MCObjectWriter &Writer,
|
|||||||
VecOS.flush();
|
VecOS.flush();
|
||||||
|
|
||||||
// Update the instruction fragment.
|
// Update the instruction fragment.
|
||||||
int SlideAmount = Code.size() - IF.getInstSize();
|
|
||||||
IF.setInst(Relaxed);
|
IF.setInst(Relaxed);
|
||||||
IF.getCode() = Code;
|
IF.getCode() = Code;
|
||||||
IF.getFixups().clear();
|
IF.getFixups().clear();
|
||||||
@ -827,8 +826,6 @@ bool MCAssembler::RelaxInstruction(const MCObjectWriter &Writer,
|
|||||||
for (unsigned i = 0, e = Fixups.size(); i != e; ++i)
|
for (unsigned i = 0, e = Fixups.size(); i != e; ++i)
|
||||||
IF.getFixups().push_back(Fixups[i]);
|
IF.getFixups().push_back(Fixups[i]);
|
||||||
|
|
||||||
// Update the layout, and remember that we relaxed.
|
|
||||||
Layout.UpdateForSlide(&IF, SlideAmount);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -894,24 +891,29 @@ bool MCAssembler::LayoutOnce(const MCObjectWriter &Writer,
|
|||||||
for (MCSectionData::iterator it2 = SD.begin(),
|
for (MCSectionData::iterator it2 = SD.begin(),
|
||||||
ie2 = SD.end(); it2 != ie2; ++it2) {
|
ie2 = SD.end(); it2 != ie2; ++it2) {
|
||||||
// Check if this is an fragment that needs relaxation.
|
// Check if this is an fragment that needs relaxation.
|
||||||
|
bool relaxedFrag = false;
|
||||||
switch(it2->getKind()) {
|
switch(it2->getKind()) {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
case MCFragment::FT_Inst:
|
case MCFragment::FT_Inst:
|
||||||
WasRelaxed |= RelaxInstruction(Writer, Layout,
|
relaxedFrag = RelaxInstruction(Writer, Layout,
|
||||||
*cast<MCInstFragment>(it2));
|
*cast<MCInstFragment>(it2));
|
||||||
break;
|
break;
|
||||||
case MCFragment::FT_Org:
|
case MCFragment::FT_Org:
|
||||||
WasRelaxed |= RelaxOrg(Writer, Layout, *cast<MCOrgFragment>(it2));
|
relaxedFrag = RelaxOrg(Writer, Layout, *cast<MCOrgFragment>(it2));
|
||||||
break;
|
break;
|
||||||
case MCFragment::FT_Dwarf:
|
case MCFragment::FT_Dwarf:
|
||||||
WasRelaxed |= RelaxDwarfLineAddr(Writer, Layout,
|
relaxedFrag = RelaxDwarfLineAddr(Writer, Layout,
|
||||||
*cast<MCDwarfLineAddrFragment>(it2));
|
*cast<MCDwarfLineAddrFragment>(it2));
|
||||||
break;
|
break;
|
||||||
case MCFragment::FT_LEB:
|
case MCFragment::FT_LEB:
|
||||||
WasRelaxed |= RelaxLEB(Writer, Layout, *cast<MCLEBFragment>(it2));
|
relaxedFrag = RelaxLEB(Writer, Layout, *cast<MCLEBFragment>(it2));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// Update the layout, and remember that we relaxed.
|
||||||
|
if (relaxedFrag)
|
||||||
|
Layout.Invalidate(it2);
|
||||||
|
WasRelaxed |= relaxedFrag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user