[llvm] r238617 - Remove getData.
Rafael Espindola
rafael.espindola at gmail.com
Fri May 29 14:45:01 PDT 2015
Author: rafael
Date: Fri May 29 16:45:01 2015
New Revision: 238617
URL: http://llvm.org/viewvc/llvm-project?rev=238617&view=rev
Log:
Remove getData.
This completes the mechanical part of merging MCSymbol and MCSymbolData.
Modified:
llvm/trunk/include/llvm/MC/MCSymbol.h
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/lib/MC/MCAssembler.cpp
llvm/trunk/lib/MC/MCELFStreamer.cpp
llvm/trunk/lib/MC/MCExpr.cpp
llvm/trunk/lib/MC/MCMachOStreamer.cpp
llvm/trunk/lib/MC/MCObjectStreamer.cpp
llvm/trunk/lib/MC/MCObjectWriter.cpp
llvm/trunk/lib/MC/MachObjectWriter.cpp
llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
llvm/trunk/lib/MC/WinCOFFStreamer.cpp
llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp
llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp
llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
Modified: llvm/trunk/include/llvm/MC/MCSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSymbol.h?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCSymbol.h (original)
+++ llvm/trunk/include/llvm/MC/MCSymbol.h Fri May 29 16:45:01 2015
@@ -117,8 +117,6 @@ public:
bool hasData() const { return HasData; }
- MCSymbol &getData() const { return *const_cast<MCSymbol *>(this); }
-
/// Initialize symbol data.
///
/// Nothing really to do here, but this is enables an assertion that \a
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Fri May 29 16:45:01 2015
@@ -359,8 +359,7 @@ void ELFObjectWriter::writeHeader(const
uint64_t ELFObjectWriter::SymbolValue(const MCSymbol &Sym,
const MCAsmLayout &Layout) {
- MCSymbol &Data = Sym.getData();
- if (Sym.isCommon() && Data.isExternal())
+ if (Sym.isCommon() && Sym.isExternal())
return Sym.getCommonAlignment();
uint64_t Res;
@@ -379,8 +378,6 @@ void ELFObjectWriter::ExecutePostLayoutB
// versions declared with @@@ to be renamed.
for (const MCSymbol &Alias : Asm.symbols()) {
- MCSymbol &OriginalData = Alias.getData();
-
// Not an alias.
if (!Alias.isVariable())
continue;
@@ -388,7 +385,6 @@ void ELFObjectWriter::ExecutePostLayoutB
if (!Ref)
continue;
const MCSymbol &Symbol = Ref->getSymbol();
- MCSymbol &SD = Symbol.getData();
StringRef AliasName = Alias.getName();
size_t Pos = AliasName.find('@');
@@ -397,7 +393,7 @@ void ELFObjectWriter::ExecutePostLayoutB
// Aliases defined with .symvar copy the binding from the symbol they alias.
// This is the first place we are able to copy this information.
- OriginalData.setExternal(SD.isExternal());
+ Alias.setExternal(Symbol.isExternal());
MCELF::SetBinding(Alias, MCELF::GetBinding(Symbol));
StringRef Rest = AliasName.substr(Pos);
@@ -451,33 +447,28 @@ static uint8_t mergeTypeForSet(uint8_t o
void ELFObjectWriter::writeSymbol(SymbolTableWriter &Writer,
uint32_t StringIndex, ELFSymbolData &MSD,
const MCAsmLayout &Layout) {
-#ifndef NDEBUG
- MCSymbol &OrigData = MSD.Symbol->getData();
- assert((!OrigData.getFragment() ||
- (OrigData.getFragment()->getParent() == &MSD.Symbol->getSection())) &&
+ const MCSymbol &Symbol = *MSD.Symbol;
+ assert((!Symbol.getFragment() ||
+ (Symbol.getFragment()->getParent() == &Symbol.getSection())) &&
"The symbol's section doesn't match the fragment's symbol");
-#endif
- const MCSymbol *Base = Layout.getBaseSymbol(*MSD.Symbol);
+ const MCSymbol *Base = Layout.getBaseSymbol(Symbol);
// This has to be in sync with when computeSymbolTable uses SHN_ABS or
// SHN_COMMON.
- bool IsReserved = !Base || MSD.Symbol->isCommon();
+ bool IsReserved = !Base || Symbol.isCommon();
// Binding and Type share the same byte as upper and lower nibbles
- uint8_t Binding = MCELF::GetBinding(*MSD.Symbol);
- uint8_t Type = MCELF::GetType(*MSD.Symbol);
- MCSymbol *BaseSD = nullptr;
+ uint8_t Binding = MCELF::GetBinding(Symbol);
+ uint8_t Type = MCELF::GetType(Symbol);
if (Base) {
- BaseSD = &Base->getData();
Type = mergeTypeForSet(Type, MCELF::GetType(*Base));
}
uint8_t Info = (Binding << ELF_STB_Shift) | (Type << ELF_STT_Shift);
// Other and Visibility share the same byte with Visibility using the lower
// 2 bits
- uint8_t Visibility = MCELF::GetVisibility(*MSD.Symbol);
- uint8_t Other = MCELF::getOther(*MSD.Symbol)
- << (ELF_STO_Shift - ELF_STV_Shift);
+ uint8_t Visibility = MCELF::GetVisibility(Symbol);
+ uint8_t Other = MCELF::getOther(Symbol) << (ELF_STO_Shift - ELF_STV_Shift);
Other |= Visibility;
uint64_t Value = SymbolValue(*MSD.Symbol, Layout);
@@ -769,8 +760,7 @@ bool ELFObjectWriter::isInSymtab(const M
bool ELFObjectWriter::isLocal(const MCSymbol &Symbol, bool IsUsedInReloc,
bool IsSignature) {
- const MCSymbol &Data = Symbol.getData();
- if (Data.isExternal())
+ if (Symbol.isExternal())
return false;
if (Symbol.isDefined())
Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Fri May 29 16:45:01 2015
@@ -120,14 +120,13 @@ uint64_t MCAsmLayout::getFragmentOffset(
// Simple getSymbolOffset helper for the non-varibale case.
static bool getLabelOffset(const MCAsmLayout &Layout, const MCSymbol &S,
bool ReportError, uint64_t &Val) {
- const MCSymbol &SD = S.getData();
- if (!SD.getFragment()) {
+ if (!S.getFragment()) {
if (ReportError)
report_fatal_error("unable to evaluate offset to undefined symbol '" +
S.getName() + "'");
return false;
}
- Val = Layout.getFragmentOffset(SD.getFragment()) + S.getOffset();
+ Val = Layout.getFragmentOffset(S.getFragment()) + S.getOffset();
return true;
}
@@ -377,17 +376,17 @@ const MCSymbol *MCAssembler::getAtom(con
return &S;
// Absolute and undefined symbols have no defining atom.
- if (!S.getData().getFragment())
+ if (!S.getFragment())
return nullptr;
// Non-linker visible symbols in sections which can't be atomized have no
// defining atom.
if (!getContext().getAsmInfo()->isSectionAtomizableBySymbols(
- *S.getData().getFragment()->getParent()))
+ *S.getFragment()->getParent()))
return nullptr;
// Otherwise, return the atom for the containing fragment.
- return S.getData().getFragment()->getAtom();
+ return S.getFragment()->getAtom();
}
bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout,
@@ -1200,7 +1199,6 @@ void MCAssembler::dump() {
OS << "(";
it->dump();
OS << ", Index:" << it->getIndex() << ", ";
- it->getData().dump();
OS << ")";
}
OS << "]>\n";
Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCELFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCELFStreamer.cpp Fri May 29 16:45:01 2015
@@ -214,7 +214,6 @@ bool MCELFStreamer::EmitSymbolAttribute(
// important side effect of calling registerSymbol here is to register
// the symbol with the assembler.
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
// The implementation of symbol attributes is designed to match 'as', but it
// leaves much to desired. It doesn't really make sense to arbitrarily add and
@@ -241,26 +240,26 @@ bool MCELFStreamer::EmitSymbolAttribute(
MCELF::SetType(
*Symbol, CombineSymbolTypes(MCELF::GetType(*Symbol), ELF::STT_OBJECT));
MCELF::SetBinding(*Symbol, ELF::STB_GNU_UNIQUE);
- SD.setExternal(true);
+ Symbol->setExternal(true);
BindingExplicitlySet.insert(Symbol);
break;
case MCSA_Global:
MCELF::SetBinding(*Symbol, ELF::STB_GLOBAL);
- SD.setExternal(true);
+ Symbol->setExternal(true);
BindingExplicitlySet.insert(Symbol);
break;
case MCSA_WeakReference:
case MCSA_Weak:
MCELF::SetBinding(*Symbol, ELF::STB_WEAK);
- SD.setExternal(true);
+ Symbol->setExternal(true);
BindingExplicitlySet.insert(Symbol);
break;
case MCSA_Local:
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
- SD.setExternal(false);
+ Symbol->setExternal(false);
BindingExplicitlySet.insert(Symbol);
break;
@@ -314,11 +313,10 @@ bool MCELFStreamer::EmitSymbolAttribute(
void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlignment) {
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
if (!BindingExplicitlySet.count(Symbol)) {
MCELF::SetBinding(*Symbol, ELF::STB_GLOBAL);
- SD.setExternal(true);
+ Symbol->setExternal(true);
}
MCELF::SetType(*Symbol, ELF::STT_OBJECT);
@@ -346,9 +344,8 @@ void MCELFStreamer::EmitLocalCommonSymbo
unsigned ByteAlignment) {
// FIXME: Should this be caught and done earlier?
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
- SD.setExternal(false);
+ Symbol->setExternal(false);
BindingExplicitlySet.insert(Symbol);
EmitCommonSymbol(Symbol, Size, ByteAlignment);
}
@@ -648,7 +645,7 @@ void MCELFStreamer::Flush() {
new MCAlignFragment(ByteAlignment, 0, 1, ByteAlignment, &Section);
MCFragment *F = new MCFillFragment(0, 0, Size, &Section);
- Symbol.getData().setFragment(F);
+ Symbol.setFragment(F);
// Update the maximum alignment of the section if necessary.
if (ByteAlignment > Section.getAlignment())
Modified: llvm/trunk/lib/MC/MCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Fri May 29 16:45:01 2015
@@ -471,10 +471,7 @@ static void AttemptToFoldSymbolOffsetDif
if (!Asm->getWriter().IsSymbolRefDifferenceFullyResolved(*Asm, A, B, InSet))
return;
- const MCSymbol &AD = SA.getData();
- const MCSymbol &BD = SB.getData();
-
- if (AD.getFragment() == BD.getFragment()) {
+ if (SA.getFragment() == SB.getFragment()) {
Addend += (SA.getOffset() - SB.getOffset());
// Pointers to Thumb symbols need to have their low-bit set to allow
@@ -491,8 +488,8 @@ static void AttemptToFoldSymbolOffsetDif
if (!Layout)
return;
- const MCSection &SecA = *AD.getFragment()->getParent();
- const MCSection &SecB = *BD.getFragment()->getParent();
+ const MCSection &SecA = *SA.getFragment()->getParent();
+ const MCSection &SecB = *SB.getFragment()->getParent();
if ((&SecA != &SecB) && !Addrs)
return;
Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Fri May 29 16:45:01 2015
@@ -173,12 +173,11 @@ void MCMachOStreamer::ChangeSection(MCSe
void MCMachOStreamer::EmitEHSymAttributes(const MCSymbol *Symbol,
MCSymbol *EHSymbol) {
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
- if (SD.isExternal())
+ if (Symbol->isExternal())
EmitSymbolAttribute(EHSymbol, MCSA_Global);
if (Symbol->getFlags() & SF_WeakDefinition)
EmitSymbolAttribute(EHSymbol, MCSA_WeakDefinition);
- if (SD.isPrivateExtern())
+ if (Symbol->isPrivateExtern())
EmitSymbolAttribute(EHSymbol, MCSA_PrivateExtern);
}
@@ -296,7 +295,6 @@ bool MCMachOStreamer::EmitSymbolAttribut
// important side effect of calling registerSymbol here is to register
// the symbol with the assembler.
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
// The implementation of symbol attributes is designed to match 'as', but it
// leaves much to desired. It doesn't really make sense to arbitrarily add and
@@ -322,7 +320,7 @@ bool MCMachOStreamer::EmitSymbolAttribut
return false;
case MCSA_Global:
- SD.setExternal(true);
+ Symbol->setExternal(true);
// This effectively clears the undefined lazy bit, in Darwin 'as', although
// it isn't very consistent because it implements this as part of symbol
// lookup.
@@ -351,8 +349,8 @@ bool MCMachOStreamer::EmitSymbolAttribut
break;
case MCSA_PrivateExtern:
- SD.setExternal(true);
- SD.setPrivateExtern(true);
+ Symbol->setExternal(true);
+ Symbol->setPrivateExtern(true);
break;
case MCSA_WeakReference:
@@ -391,8 +389,7 @@ void MCMachOStreamer::EmitCommonSymbol(M
AssignSection(Symbol, nullptr);
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
- SD.setExternal(true);
+ Symbol->setExternal(true);
Symbol->setCommon(Size, ByteAlignment);
}
@@ -417,14 +414,13 @@ void MCMachOStreamer::EmitZerofill(MCSec
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
// Emit an align fragment if necessary.
if (ByteAlignment != 1)
new MCAlignFragment(ByteAlignment, 0, 0, ByteAlignment, Section);
MCFragment *F = new MCFillFragment(0, 0, Size, Section);
- SD.setFragment(F);
+ Symbol->setFragment(F);
AssignSection(Symbol, Section);
@@ -469,12 +465,11 @@ void MCMachOStreamer::FinishImpl() {
// defining symbols.
DenseMap<const MCFragment *, const MCSymbol *> DefiningSymbolMap;
for (const MCSymbol &Symbol : getAssembler().symbols()) {
- MCSymbol &SD = Symbol.getData();
- if (getAssembler().isSymbolLinkerVisible(Symbol) && SD.getFragment()) {
+ if (getAssembler().isSymbolLinkerVisible(Symbol) && Symbol.getFragment()) {
// An atom defining symbol should never be internal to a fragment.
assert(Symbol.getOffset() == 0 &&
"Invalid offset in atom defining symbol!");
- DefiningSymbolMap[SD.getFragment()] = &Symbol;
+ DefiningSymbolMap[Symbol.getFragment()] = &Symbol;
}
}
Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Fri May 29 16:45:01 2015
@@ -47,8 +47,7 @@ void MCObjectStreamer::flushPendingLabel
F->setParent(CurSection);
}
for (MCSymbol *Sym : PendingLabels) {
- MCSymbol *SD = &Sym->getData();
- SD->setFragment(F);
+ Sym->setFragment(F);
Sym->setOffset(FOffset);
}
PendingLabels.clear();
@@ -61,15 +60,13 @@ bool MCObjectStreamer::emitAbsoluteSymbo
// Must have symbol data.
if (!Assembler->hasSymbolData(*Hi) || !Assembler->hasSymbolData(*Lo))
return false;
- auto &HiD = Hi->getData();
- auto &LoD = Lo->getData();
// Must both be assigned to the same (valid) fragment.
- if (!HiD.getFragment() || HiD.getFragment() != LoD.getFragment())
+ if (!Hi->getFragment() || Hi->getFragment() != Lo->getFragment())
return false;
// Must be a data fragment.
- if (!isa<MCDataFragment>(HiD.getFragment()))
+ if (!isa<MCDataFragment>(Hi->getFragment()))
return false;
assert(Hi->getOffset() >= Lo->getOffset() &&
@@ -164,8 +161,7 @@ void MCObjectStreamer::EmitLabel(MCSymbo
MCStreamer::EmitLabel(Symbol);
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
- assert(!SD.getFragment() && "Unexpected fragment on symbol data!");
+ assert(!Symbol->getFragment() && "Unexpected fragment on symbol data!");
// If there is a current fragment, mark the symbol as pointing into it.
// Otherwise queue the label and set its fragment pointer when we emit the
@@ -173,7 +169,7 @@ void MCObjectStreamer::EmitLabel(MCSymbo
auto *F = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
if (F && !(getAssembler().isBundlingEnabled() &&
getAssembler().getRelaxAll())) {
- SD.setFragment(F);
+ Symbol->setFragment(F);
Symbol->setOffset(F->getContents().size());
} else {
PendingLabels.push_back(Symbol);
Modified: llvm/trunk/lib/MC/MCObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectWriter.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectWriter.cpp Fri May 29 16:45:01 2015
@@ -30,12 +30,10 @@ bool MCObjectWriter::IsSymbolRefDifferen
if (SA.isUndefined() || SB.isUndefined())
return false;
- const MCSymbol &DataA = SA.getData();
- const MCSymbol &DataB = SB.getData();
- if(!DataA.getFragment() || !DataB.getFragment())
+ if (!SA.getFragment() || !SB.getFragment())
return false;
- return IsSymbolRefDifferenceFullyResolvedImpl(Asm, SA, *DataB.getFragment(),
+ return IsSymbolRefDifferenceFullyResolvedImpl(Asm, SA, *SB.getFragment(),
InSet, false);
}
Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/MachObjectWriter.cpp Fri May 29 16:45:01 2015
@@ -101,7 +101,7 @@ uint64_t MachObjectWriter::getSymbolAddr
return Address;
}
- return getSectionAddress(S.getData().getFragment()->getParent()) +
+ return getSectionAddress(S.getFragment()->getParent()) +
Layout.getSymbolOffset(S);
}
@@ -329,7 +329,7 @@ const MCSymbol &MachObjectWriter::findAl
void MachObjectWriter::WriteNlist(MachSymbolData &MSD,
const MCAsmLayout &Layout) {
const MCSymbol *Symbol = MSD.Symbol;
- MCSymbol &Data = Symbol->getData();
+ const MCSymbol &Data = *Symbol;
const MCSymbol *AliasedSymbol = &findAliasedSymbol(*Symbol);
uint8_t SectionIndex = MSD.SectionIndex;
uint8_t Type = 0;
@@ -554,13 +554,11 @@ void MachObjectWriter::ComputeSymbolTabl
// match 'as'. Even though it doesn't matter for correctness, this is
// important for letting us diff .o files.
for (const MCSymbol &Symbol : Asm.symbols()) {
- MCSymbol &SD = Symbol.getData();
-
// Ignore non-linker visible symbols.
if (!Asm.isSymbolLinkerVisible(Symbol))
continue;
- if (!SD.isExternal() && !Symbol.isUndefined())
+ if (!Symbol.isExternal() && !Symbol.isUndefined())
continue;
MachSymbolData MSD;
@@ -582,13 +580,11 @@ void MachObjectWriter::ComputeSymbolTabl
// Now add the data for local symbols.
for (const MCSymbol &Symbol : Asm.symbols()) {
- MCSymbol &SD = Symbol.getData();
-
// Ignore non-linker visible symbols.
if (!Asm.isSymbolLinkerVisible(Symbol))
continue;
- if (SD.isExternal() || Symbol.isUndefined())
+ if (Symbol.isExternal() || Symbol.isUndefined())
continue;
MachSymbolData MSD;
@@ -692,8 +688,7 @@ bool MachObjectWriter::IsSymbolRefDiffer
bool hasReliableSymbolDifference = isX86_64();
if (!hasReliableSymbolDifference) {
if (!SA.isInSection() || &SecA != &SecB ||
- (!SA.isTemporary() &&
- FB.getAtom() != SA.getData().getFragment()->getAtom() &&
+ (!SA.isTemporary() && FB.getAtom() != SA.getFragment()->getAtom() &&
Asm.getSubsectionsViaSymbols()))
return false;
return true;
@@ -717,7 +712,7 @@ bool MachObjectWriter::IsSymbolRefDiffer
if (&SecA != &SecB)
return false;
- const MCFragment *FA = SA.getData().getFragment();
+ const MCFragment *FA = SA.getFragment();
// Bail if the symbol has no fragment.
if (!FA)
@@ -968,7 +963,7 @@ void MachObjectWriter::WriteObject(MCAss
static_cast<const MCSectionMachO &>(*it->Section);
if (Section.getType() == MachO::S_NON_LAZY_SYMBOL_POINTERS) {
// If this symbol is defined and internal, mark it as such.
- if (it->Symbol->isDefined() && !it->Symbol->getData().isExternal()) {
+ if (it->Symbol->isDefined() && !it->Symbol->isExternal()) {
uint32_t Flags = MachO::INDIRECT_SYMBOL_LOCAL;
if (it->Symbol->isAbsolute())
Flags |= MachO::INDIRECT_SYMBOL_ABS;
Modified: llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFObjectWriter.cpp Fri May 29 16:45:01 2015
@@ -364,8 +364,7 @@ void WinCOFFObjectWriter::defineSection(
static uint64_t getSymbolValue(const MCSymbol &Symbol,
const MCAsmLayout &Layout) {
- const MCSymbol &Data = Symbol.getData();
- if (Symbol.isCommon() && Data.isExternal())
+ if (Symbol.isCommon() && Symbol.isExternal())
return Symbol.getCommonSize();
uint64_t Res;
@@ -414,7 +413,6 @@ void WinCOFFObjectWriter::DefineSymbol(c
coff_symbol->MC = &Symbol;
} else {
- const MCSymbol &ResSymData = Symbol.getData();
const MCSymbol *Base = Layout.getBaseSymbol(Symbol);
coff_symbol->Data.Value = getSymbolValue(Symbol, Layout);
@@ -423,8 +421,8 @@ void WinCOFFObjectWriter::DefineSymbol(c
// If no storage class was specified in the streamer, define it here.
if (coff_symbol->Data.StorageClass == 0) {
- bool IsExternal = ResSymData.isExternal() ||
- (!ResSymData.getFragment() && !Symbol.isVariable());
+ bool IsExternal = Symbol.isExternal() ||
+ (!Symbol.getFragment() && !Symbol.isVariable());
coff_symbol->Data.StorageClass = IsExternal
? COFF::IMAGE_SYM_CLASS_EXTERNAL
@@ -434,9 +432,8 @@ void WinCOFFObjectWriter::DefineSymbol(c
if (!Base) {
coff_symbol->Data.SectionNumber = COFF::IMAGE_SYM_ABSOLUTE;
} else {
- const MCSymbol &BaseData = Base->getData();
- if (BaseData.getFragment()) {
- COFFSection *Sec = SectionMap[BaseData.getFragment()->getParent()];
+ if (Base->getFragment()) {
+ COFFSection *Sec = SectionMap[Base->getFragment()->getParent()];
if (coff_symbol->Section && coff_symbol->Section != Sec)
report_fatal_error("conflicting sections for symbol");
@@ -672,8 +669,7 @@ bool WinCOFFObjectWriter::IsSymbolRefDif
}
bool WinCOFFObjectWriter::isWeak(const MCSymbol &Sym) const {
- const MCSymbol &SD = Sym.getData();
- if (!SD.isExternal())
+ if (!Sym.isExternal())
return false;
if (!Sym.isInSection())
@@ -701,8 +697,6 @@ void WinCOFFObjectWriter::RecordRelocati
Twine("symbol '") + A.getName() +
"' can not be undefined");
- const MCSymbol &A_SD = A.getData();
-
MCSection *Section = Fragment->getParent();
// Mark this symbol as requiring an entry in the symbol table.
@@ -718,14 +712,13 @@ void WinCOFFObjectWriter::RecordRelocati
if (SymB) {
const MCSymbol *B = &SymB->getSymbol();
- const MCSymbol &B_SD = B->getData();
- if (!B_SD.getFragment())
+ if (!B->getFragment())
Asm.getContext().reportFatalError(
Fixup.getLoc(),
Twine("symbol '") + B->getName() +
"' can not be undefined in a subtraction expression");
- if (!A_SD.getFragment())
+ if (!A.getFragment())
Asm.getContext().reportFatalError(
Fixup.getLoc(),
Twine("symbol '") + Symbol.getName() +
@@ -762,9 +755,8 @@ void WinCOFFObjectWriter::RecordRelocati
// Turn relocations for temporary symbols into section relocations.
if (coff_symbol->MC->isTemporary() || CrossSection) {
Reloc.Symb = coff_symbol->Section->Symbol;
- FixedValue +=
- Layout.getFragmentOffset(coff_symbol->MC->getData().getFragment()) +
- coff_symbol->MC->getOffset();
+ FixedValue += Layout.getFragmentOffset(coff_symbol->MC->getFragment()) +
+ coff_symbol->MC->getOffset();
} else
Reloc.Symb = coff_symbol;
Modified: llvm/trunk/lib/MC/WinCOFFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WinCOFFStreamer.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WinCOFFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/WinCOFFStreamer.cpp Fri May 29 16:45:01 2015
@@ -97,17 +97,16 @@ bool MCWinCOFFStreamer::EmitSymbolAttrib
"Got non-COFF section in the COFF backend!");
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
switch (Attribute) {
default: return false;
case MCSA_WeakReference:
case MCSA_Weak:
Symbol->modifyFlags(COFF::SF_WeakExternal, COFF::SF_WeakExternal);
- SD.setExternal(true);
+ Symbol->setExternal(true);
break;
case MCSA_Global:
- SD.setExternal(true);
+ Symbol->setExternal(true);
break;
}
@@ -197,8 +196,7 @@ void MCWinCOFFStreamer::EmitCommonSymbol
AssignSection(Symbol, nullptr);
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
- SD.setExternal(true);
+ Symbol->setExternal(true);
Symbol->setCommon(Size, ByteAlignment);
if (!T.isKnownWindowsMSVCEnvironment() && ByteAlignment > 1) {
@@ -227,8 +225,7 @@ void MCWinCOFFStreamer::EmitLocalCommonS
Section->setAlignment(ByteAlignment);
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
- SD.setExternal(false);
+ Symbol->setExternal(false);
AssignSection(Symbol, Section);
@@ -238,7 +235,7 @@ void MCWinCOFFStreamer::EmitLocalCommonS
MCFillFragment *Fragment = new MCFillFragment(
/*Value=*/0, /*ValueSize=*/0, Size, Section);
- SD.setFragment(Fragment);
+ Symbol->setFragment(Fragment);
}
void MCWinCOFFStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
Modified: llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp Fri May 29 16:45:01 2015
@@ -165,10 +165,9 @@ private:
Name + "." + Twine(MappingSymbolCounter++));
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
- SD.setExternal(false);
+ Symbol->setExternal(false);
auto Sec = getCurrentSection().first;
assert(Sec && "need a section");
Symbol->setSection(*Sec);
Modified: llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp Fri May 29 16:45:01 2015
@@ -209,11 +209,9 @@ void AArch64MachObjectWriter::RecordRelo
}
} else if (Target.getSymB()) { // A - B + constant
const MCSymbol *A = &Target.getSymA()->getSymbol();
- const MCSymbol &A_SD = A->getData();
const MCSymbol *A_Base = Asm.getAtom(*A);
const MCSymbol *B = &Target.getSymB()->getSymbol();
- const MCSymbol &B_SD = B->getData();
const MCSymbol *B_Base = Asm.getAtom(*B);
// Check for "_foo at got - .", which comes through here as:
@@ -264,14 +262,12 @@ void AArch64MachObjectWriter::RecordRelo
Asm.getContext().reportFatalError(Fixup.getLoc(),
"unsupported relocation with identical base");
- Value += (!A_SD.getFragment() ? 0 : Writer->getSymbolAddress(*A, Layout)) -
- (!A_Base || !A_Base->getData().getFragment()
- ? 0
- : Writer->getSymbolAddress(*A_Base, Layout));
- Value -= (!B_SD.getFragment() ? 0 : Writer->getSymbolAddress(*B, Layout)) -
- (!B_Base || !B_Base->getData().getFragment()
- ? 0
- : Writer->getSymbolAddress(*B_Base, Layout));
+ Value += (!A->getFragment() ? 0 : Writer->getSymbolAddress(*A, Layout)) -
+ (!A_Base || !A_Base->getFragment() ? 0 : Writer->getSymbolAddress(
+ *A_Base, Layout));
+ Value -= (!B->getFragment() ? 0 : Writer->getSymbolAddress(*B, Layout)) -
+ (!B_Base || !B_Base->getFragment() ? 0 : Writer->getSymbolAddress(
+ *B_Base, Layout));
Type = MachO::ARM64_RELOC_UNSIGNED;
Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp Fri May 29 16:45:01 2015
@@ -601,8 +601,7 @@ void ARMAsmBackend::processFixupValue(co
// the offset when the destination has the same MCFragment.
if (A && (unsigned)Fixup.getKind() == ARM::fixup_arm_thumb_bl) {
const MCSymbol &Sym = A->getSymbol();
- const MCSymbol &SymData = Sym.getData();
- IsResolved = (SymData.getFragment() == DF);
+ IsResolved = (Sym.getFragment() == DF);
}
// We must always generate a relocation for BL/BLX instructions if we have
// a symbol to reference, as the linker relies on knowing the destination
Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp Fri May 29 16:45:01 2015
@@ -567,10 +567,9 @@ private:
Twine(MappingSymbolCounter++));
getAssembler().registerSymbol(*Symbol);
- MCSymbol &SD = Symbol->getData();
MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
- SD.setExternal(false);
+ Symbol->setExternal(false);
AssignSection(Symbol, getCurrentSection().first);
const MCExpr *Value = MCSymbolRefExpr::Create(Start, getContext());
Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMachObjectWriter.cpp Fri May 29 16:45:01 2015
@@ -152,23 +152,21 @@ RecordARMScatteredHalfRelocation(MachObj
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
- const MCSymbol *A_SD = &A->getData();
- if (!A_SD->getFragment())
+ if (!A->getFragment())
Asm.getContext().reportFatalError(Fixup.getLoc(),
"symbol '" + A->getName() +
"' can not be undefined in a subtraction expression");
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
uint32_t Value2 = 0;
- uint64_t SecAddr =
- Writer->getSectionAddress(A_SD->getFragment()->getParent());
+ uint64_t SecAddr = Writer->getSectionAddress(A->getFragment()->getParent());
FixedValue += SecAddr;
if (const MCSymbolRefExpr *B = Target.getSymB()) {
- const MCSymbol *B_SD = &B->getSymbol().getData();
+ const MCSymbol *SB = &B->getSymbol();
- if (!B_SD->getFragment())
+ if (!SB->getFragment())
Asm.getContext().reportFatalError(Fixup.getLoc(),
"symbol '" + B->getSymbol().getName() +
"' can not be undefined in a subtraction expression");
@@ -176,7 +174,7 @@ RecordARMScatteredHalfRelocation(MachObj
// Select the appropriate difference relocation type.
Type = MachO::ARM_RELOC_HALF_SECTDIFF;
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
- FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
+ FixedValue -= Writer->getSectionAddress(SB->getFragment()->getParent());
}
// Relocations are written out in reverse order, so the PAIR comes first.
@@ -255,24 +253,22 @@ void ARMMachObjectWriter::RecordARMScatt
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
- const MCSymbol *A_SD = &A->getData();
- if (!A_SD->getFragment())
+ if (!A->getFragment())
Asm.getContext().reportFatalError(Fixup.getLoc(),
"symbol '" + A->getName() +
"' can not be undefined in a subtraction expression");
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
- uint64_t SecAddr =
- Writer->getSectionAddress(A_SD->getFragment()->getParent());
+ uint64_t SecAddr = Writer->getSectionAddress(A->getFragment()->getParent());
FixedValue += SecAddr;
uint32_t Value2 = 0;
if (const MCSymbolRefExpr *B = Target.getSymB()) {
assert(Type == MachO::ARM_RELOC_VANILLA && "invalid reloc for 2 symbols");
- const MCSymbol *B_SD = &B->getSymbol().getData();
+ const MCSymbol *SB = &B->getSymbol();
- if (!B_SD->getFragment())
+ if (!SB->getFragment())
Asm.getContext().reportFatalError(Fixup.getLoc(),
"symbol '" + B->getSymbol().getName() +
"' can not be undefined in a subtraction expression");
@@ -280,7 +276,7 @@ void ARMMachObjectWriter::RecordARMScatt
// Select the appropriate difference relocation type.
Type = MachO::ARM_RELOC_SECTDIFF;
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
- FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
+ FixedValue -= Writer->getSectionAddress(SB->getFragment()->getParent());
}
// Relocations are written out in reverse order, so the PAIR comes first.
Modified: llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMachObjectWriter.cpp Fri May 29 16:45:01 2015
@@ -206,28 +206,26 @@ bool PPCMachObjectWriter::RecordScattere
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
- const MCSymbol *A_SD = &A->getData();
- if (!A_SD->getFragment())
+ if (!A->getFragment())
report_fatal_error("symbol '" + A->getName() +
"' can not be undefined in a subtraction expression");
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
- uint64_t SecAddr =
- Writer->getSectionAddress(A_SD->getFragment()->getParent());
+ uint64_t SecAddr = Writer->getSectionAddress(A->getFragment()->getParent());
FixedValue += SecAddr;
uint32_t Value2 = 0;
if (const MCSymbolRefExpr *B = Target.getSymB()) {
- const MCSymbol *B_SD = &B->getSymbol().getData();
+ const MCSymbol *SB = &B->getSymbol();
- if (!B_SD->getFragment())
+ if (!SB->getFragment())
report_fatal_error("symbol '" + B->getSymbol().getName() +
"' can not be undefined in a subtraction expression");
// FIXME: is Type correct? see include/llvm/Support/MachO.h
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
- FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
+ FixedValue -= Writer->getSectionAddress(SB->getFragment()->getParent());
}
// FIXME: does FixedValue get used??
Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp?rev=238617&r1=238616&r2=238617&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp Fri May 29 16:45:01 2015
@@ -142,13 +142,11 @@ void X86MachObjectWriter::RecordX86_64Re
const MCSymbol *A = &Target.getSymA()->getSymbol();
if (A->isTemporary())
A = &Writer->findAliasedSymbol(*A);
- const MCSymbol &A_SD = A->getData();
const MCSymbol *A_Base = Asm.getAtom(*A);
const MCSymbol *B = &Target.getSymB()->getSymbol();
if (B->isTemporary())
B = &Writer->findAliasedSymbol(*B);
- const MCSymbol &B_SD = B->getData();
const MCSymbol *B_Base = Asm.getAtom(*B);
// Neither symbol can be modified.
@@ -190,7 +188,7 @@ void X86MachObjectWriter::RecordX86_64Re
(!B_Base ? 0 : Writer->getSymbolAddress(*B_Base, Layout));
if (!A_Base)
- Index = A_SD.getFragment()->getParent()->getOrdinal() + 1;
+ Index = A->getFragment()->getParent()->getOrdinal() + 1;
Type = MachO::X86_64_RELOC_UNSIGNED;
MachO::any_relocation_info MRE;
@@ -202,7 +200,7 @@ void X86MachObjectWriter::RecordX86_64Re
if (B_Base)
RelSymbol = B_Base;
else
- Index = B_SD.getFragment()->getParent()->getOrdinal() + 1;
+ Index = B->getFragment()->getParent()->getOrdinal() + 1;
Type = MachO::X86_64_RELOC_SUBTRACTOR;
} else {
const MCSymbol *Symbol = &Target.getSymA()->getSymbol();
@@ -211,7 +209,6 @@ void X86MachObjectWriter::RecordX86_64Re
if (!Asm.getContext().getAsmInfo()->isSectionAtomizableBySymbols(Sec))
Asm.addLocalUsedInReloc(*Symbol);
}
- const MCSymbol &SD = Symbol->getData();
RelSymbol = Asm.getAtom(*Symbol);
// Relocations inside debug sections always use local relocations when
@@ -235,7 +232,7 @@ void X86MachObjectWriter::RecordX86_64Re
Layout.getSymbolOffset(*RelSymbol);
} else if (Symbol->isInSection() && !Symbol->isVariable()) {
// The index is the section ordinal (1-based).
- Index = SD.getFragment()->getParent()->getOrdinal() + 1;
+ Index = Symbol->getFragment()->getParent()->getOrdinal() + 1;
Value += Writer->getSymbolAddress(*Symbol, Layout);
if (IsPCRel)
@@ -354,23 +351,21 @@ bool X86MachObjectWriter::RecordScattere
// See <reloc.h>.
const MCSymbol *A = &Target.getSymA()->getSymbol();
- const MCSymbol *A_SD = &A->getData();
- if (!A_SD->getFragment())
+ if (!A->getFragment())
report_fatal_error("symbol '" + A->getName() +
"' can not be undefined in a subtraction expression",
false);
uint32_t Value = Writer->getSymbolAddress(*A, Layout);
- uint64_t SecAddr =
- Writer->getSectionAddress(A_SD->getFragment()->getParent());
+ uint64_t SecAddr = Writer->getSectionAddress(A->getFragment()->getParent());
FixedValue += SecAddr;
uint32_t Value2 = 0;
if (const MCSymbolRefExpr *B = Target.getSymB()) {
- const MCSymbol *B_SD = &B->getSymbol().getData();
+ const MCSymbol *SB = &B->getSymbol();
- if (!B_SD->getFragment())
+ if (!SB->getFragment())
report_fatal_error("symbol '" + B->getSymbol().getName() +
"' can not be undefined in a subtraction expression",
false);
@@ -380,10 +375,10 @@ bool X86MachObjectWriter::RecordScattere
// Note that there is no longer any semantic difference between these two
// relocation types from the linkers point of view, this is done solely for
// pedantic compatibility with 'as'.
- Type = A_SD->isExternal() ? (unsigned)MachO::GENERIC_RELOC_SECTDIFF :
- (unsigned)MachO::GENERIC_RELOC_LOCAL_SECTDIFF;
+ Type = A->isExternal() ? (unsigned)MachO::GENERIC_RELOC_SECTDIFF
+ : (unsigned)MachO::GENERIC_RELOC_LOCAL_SECTDIFF;
Value2 = Writer->getSymbolAddress(B->getSymbol(), Layout);
- FixedValue -= Writer->getSectionAddress(B_SD->getFragment()->getParent());
+ FixedValue -= Writer->getSectionAddress(SB->getFragment()->getParent());
}
// Relocations are written out in reverse order, so the PAIR comes first.
More information about the llvm-commits
mailing list