Skip to content

Commit

Permalink
MC: Simplify MCAssembler::isSymbolLinkerVisible to only take an MCSym…
Browse files Browse the repository at this point in the history
…bol.

llvm-svn: 106142
  • Loading branch information
ddunbar committed Jun 16, 2010
1 parent b2347fe commit aa627c3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion llvm/include/llvm/MC/MCAssembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ class MCAssembler {
/// in the symbol table, or whether it can be discarded by the assembler. This
/// also effects whether the assembler treats the label as potentially
/// defining a separate atom.
bool isSymbolLinkerVisible(const MCSymbolData *SD) const;
bool isSymbolLinkerVisible(const MCSymbol &SD) const;

/// Emit the section contents using the given object writer.
//
Expand Down
11 changes: 5 additions & 6 deletions llvm/lib/MC/MCAssembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,24 +308,23 @@ static bool isScatteredFixupFullyResolved(const MCAssembler &Asm,
return !B_Base && BaseSymbol == A_Base;
}

bool MCAssembler::isSymbolLinkerVisible(const MCSymbolData *SD) const {
bool MCAssembler::isSymbolLinkerVisible(const MCSymbol &Symbol) const {
// Non-temporary labels should always be visible to the linker.
if (!SD->getSymbol().isTemporary())
if (!Symbol.isTemporary())
return true;

// Absolute temporary labels are never visible.
if (!SD->getFragment())
if (!Symbol.isInSection())
return false;

// Otherwise, check if the section requires symbols even for temporary labels.
return getBackend().doesSectionRequireSymbols(
SD->getFragment()->getParent()->getSection());
return getBackend().doesSectionRequireSymbols(Symbol.getSection());
}

const MCSymbolData *MCAssembler::getAtom(const MCAsmLayout &Layout,
const MCSymbolData *SD) const {
// Linker visible symbols define atoms.
if (isSymbolLinkerVisible(SD))
if (isSymbolLinkerVisible(SD->getSymbol()))
return SD;

// Absolute and undefined symbols have no defining atom.
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/MC/MCMachOStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void MCMachOStreamer::EmitLabel(MCSymbol *Symbol) {

// Update the current atom map, if necessary.
bool MustCreateFragment = false;
if (getAssembler().isSymbolLinkerVisible(&SD)) {
if (getAssembler().isSymbolLinkerVisible(SD.getSymbol())) {
CurrentAtomMap[getCurrentSectionData()] = &SD;

// We have to create a new fragment, fragments cannot span atoms.
Expand Down Expand Up @@ -328,7 +328,7 @@ void MCMachOStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol,

MCFragment *F = new MCFillFragment(0, 0, Size, &SectData);
SD.setFragment(F);
if (getAssembler().isSymbolLinkerVisible(&SD))
if (getAssembler().isSymbolLinkerVisible(SD.getSymbol()))
F->setAtom(&SD);

Symbol->setSection(*Section);
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/MC/MachObjectWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ class MachObjectWriterImpl {
const MCSymbol &Symbol = it->getSymbol();

// Ignore non-linker visible symbols.
if (!Asm.isSymbolLinkerVisible(it))
if (!Asm.isSymbolLinkerVisible(it->getSymbol()))
continue;

if (!it->isExternal() && !Symbol.isUndefined())
Expand Down Expand Up @@ -972,7 +972,7 @@ class MachObjectWriterImpl {
const MCSymbol &Symbol = it->getSymbol();

// Ignore non-linker visible symbols.
if (!Asm.isSymbolLinkerVisible(it))
if (!Asm.isSymbolLinkerVisible(it->getSymbol()))
continue;

if (it->isExternal() || Symbol.isUndefined())
Expand Down

0 comments on commit aa627c3

Please sign in to comment.