aboutsummaryrefslogtreecommitdiff
path: root/lib/MC/MCAssembler.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-05-11 17:22:50 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-05-11 17:22:50 +0000
commit651804c3d63a05f72221a6d133e5b344e6aaa093 (patch)
tree68390c5775fef2161d57ae0ca425ba28b630b93b /lib/MC/MCAssembler.cpp
parentc9d0c4e801f2bb1139423ea1606ed504b510abc1 (diff)
MC/Mach-O x86_64: Switch to using fragment atom symbol.
- This eliminates getAtomForAddress() (which was a linear search) and simplifies getAtom(). - This also fixes some correctness problems where local labels at the same address as non-local labels could be assigned to the wrong atom. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103480 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCAssembler.cpp')
-rw-r--r--lib/MC/MCAssembler.cpp43
1 files changed, 6 insertions, 37 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp
index 5c2bf7879a..65e3571107 100644
--- a/lib/MC/MCAssembler.cpp
+++ b/lib/MC/MCAssembler.cpp
@@ -49,8 +49,8 @@ STATISTIC(SectionLayouts, "Number of section layouts");
void MCAsmLayout::UpdateForSlide(MCFragment *F, int SlideAmount) {
// We shouldn't have to do anything special to support negative slides, and it
- // is a perfectly valid thing to do as long as other parts of the system are
- // can guarantee convergence.
+ // is a perfectly valid thing to do as long as other parts of the system can
+ // guarantee convergence.
assert(SlideAmount >= 0 && "Negative slides not yet supported");
// Update the layout by simply recomputing the layout for the entire
@@ -287,36 +287,6 @@ bool MCAssembler::isSymbolLinkerVisible(const MCSymbolData *SD) const {
SD->getFragment()->getParent()->getSection());
}
-// FIXME-PERF: This routine is really slow.
-const MCSymbolData *MCAssembler::getAtomForAddress(const MCAsmLayout &Layout,
- const MCSectionData *Section,
- uint64_t Address) const {
- const MCSymbolData *Best = 0;
- uint64_t BestAddress = 0;
-
- for (MCAssembler::const_symbol_iterator it = symbol_begin(),
- ie = symbol_end(); it != ie; ++it) {
- // Ignore non-linker visible symbols.
- if (!isSymbolLinkerVisible(it))
- continue;
-
- // Ignore symbols not in the same section.
- if (!it->getFragment() || it->getFragment()->getParent() != Section)
- continue;
-
- // Otherwise, find the closest symbol preceding this address (ties are
- // resolved in favor of the last defined symbol).
- uint64_t SymbolAddress = Layout.getSymbolAddress(it);
- if (SymbolAddress <= Address && (!Best || SymbolAddress >= BestAddress)) {
- Best = it;
- BestAddress = SymbolAddress;
- }
- }
-
- return Best;
-}
-
-// FIXME-PERF: This routine is really slow.
const MCSymbolData *MCAssembler::getAtom(const MCAsmLayout &Layout,
const MCSymbolData *SD) const {
// Linker visible symbols define atoms.
@@ -327,9 +297,8 @@ const MCSymbolData *MCAssembler::getAtom(const MCAsmLayout &Layout,
if (!SD->getFragment())
return 0;
- // Otherwise, search by address.
- return getAtomForAddress(Layout, SD->getFragment()->getParent(),
- Layout.getSymbolAddress(SD));
+ // Otherwise, return the atom for the containing fragment.
+ return SD->getFragment()->getAtom();
}
bool MCAssembler::EvaluateFixup(const MCAsmLayout &Layout,
@@ -370,8 +339,7 @@ bool MCAssembler::EvaluateFixup(const MCAsmLayout &Layout,
// symbol) that the fixup value is relative to.
const MCSymbolData *BaseSymbol = 0;
if (IsPCRel) {
- BaseSymbol = getAtomForAddress(
- Layout, DF->getParent(), Layout.getFragmentAddress(DF)+Fixup.Offset);
+ BaseSymbol = DF->getAtom();
if (!BaseSymbol)
IsResolved = false;
}
@@ -837,6 +805,7 @@ void MCAssembler::FinishLayout(MCAsmLayout &Layout) {
//
// FIXME: Add MCAsmLayout utility for this.
DF->setParent(IF->getParent());
+ DF->setAtom(IF->getAtom());
DF->setOrdinal(IF->getOrdinal());
Layout.setFragmentOffset(DF, Layout.getFragmentOffset(IF));
Layout.setFragmentEffectiveSize(DF, Layout.getFragmentEffectiveSize(IF));