[llvm] r237803 - MC: Update MCAssembler to use MCSymbol, NFC
Duncan P. N. Exon Smith
dexonsmith at apple.com
Wed May 20 09:02:11 PDT 2015
Author: dexonsmith
Date: Wed May 20 11:02:11 2015
New Revision: 237803
URL: http://llvm.org/viewvc/llvm-project?rev=237803&view=rev
Log:
MC: Update MCAssembler to use MCSymbol, NFC
Use `MCSymbol` over `MCSymbolData` where both are needed.
Modified:
llvm/trunk/include/llvm/MC/MCAssembler.h
llvm/trunk/lib/MC/MCAssembler.cpp
llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp
llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp
Modified: llvm/trunk/include/llvm/MC/MCAssembler.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAssembler.h?rev=237803&r1=237802&r2=237803&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCAssembler.h (original)
+++ llvm/trunk/include/llvm/MC/MCAssembler.h Wed May 20 11:02:11 2015
@@ -834,7 +834,7 @@ public:
/// Find the symbol which defines the atom containing the given symbol, or
/// null if there is no such symbol.
- const MCSymbol *getAtom(const MCSymbolData *Symbol) const;
+ const MCSymbol *getAtom(const MCSymbol &S) const;
/// Check whether a particular symbol is visible to the linker and is required
/// in the symbol table, or whether it can be discarded by the assembler. This
Modified: llvm/trunk/lib/MC/MCAssembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAssembler.cpp?rev=237803&r1=237802&r2=237803&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAssembler.cpp (original)
+++ llvm/trunk/lib/MC/MCAssembler.cpp Wed May 20 11:02:11 2015
@@ -120,12 +120,13 @@ uint64_t MCAsmLayout::getFragmentOffset(
}
// Simple getSymbolOffset helper for the non-varibale case.
-static bool getLabelOffset(const MCAsmLayout &Layout, const MCSymbolData &SD,
+static bool getLabelOffset(const MCAsmLayout &Layout, const MCSymbol &S,
bool ReportError, uint64_t &Val) {
+ const MCSymbolData &SD = S.getData();
if (!SD.getFragment()) {
if (ReportError)
report_fatal_error("unable to evaluate offset to undefined symbol '" +
- SD.getSymbol().getName() + "'");
+ S.getName() + "'");
return false;
}
Val = Layout.getFragmentOffset(SD.getFragment()) + SD.getOffset();
@@ -135,7 +136,7 @@ static bool getLabelOffset(const MCAsmLa
static bool getSymbolOffsetImpl(const MCAsmLayout &Layout, const MCSymbol &S,
bool ReportError, uint64_t &Val) {
if (!S.isVariable())
- return getLabelOffset(Layout, S.getData(), ReportError, Val);
+ return getLabelOffset(Layout, S, ReportError, Val);
// If SD is a variable, evaluate it.
MCValue Target;
@@ -145,13 +146,10 @@ static bool getSymbolOffsetImpl(const MC
uint64_t Offset = Target.getConstant();
- const MCAssembler &Asm = Layout.getAssembler();
-
const MCSymbolRefExpr *A = Target.getSymA();
if (A) {
uint64_t ValA;
- if (!getLabelOffset(Layout, Asm.getSymbolData(A->getSymbol()), ReportError,
- ValA))
+ if (!getLabelOffset(Layout, A->getSymbol(), ReportError, ValA))
return false;
Offset += ValA;
}
@@ -159,8 +157,7 @@ static bool getSymbolOffsetImpl(const MC
const MCSymbolRefExpr *B = Target.getSymB();
if (B) {
uint64_t ValB;
- if (!getLabelOffset(Layout, Asm.getSymbolData(B->getSymbol()), ReportError,
- ValB))
+ if (!getLabelOffset(Layout, B->getSymbol(), ReportError, ValB))
return false;
Offset -= ValB;
}
@@ -457,23 +454,23 @@ bool MCAssembler::isSymbolLinkerVisible(
return false;
}
-const MCSymbol *MCAssembler::getAtom(const MCSymbolData *SD) const {
+const MCSymbol *MCAssembler::getAtom(const MCSymbol &S) const {
// Linker visible symbols define atoms.
- if (isSymbolLinkerVisible(SD->getSymbol()))
- return &SD->getSymbol();
+ if (isSymbolLinkerVisible(S))
+ return &S;
// Absolute and undefined symbols have no defining atom.
- if (!SD->getFragment())
+ if (!S.getData().getFragment())
return nullptr;
// Non-linker visible symbols in sections which can't be atomized have no
// defining atom.
if (!getContext().getAsmInfo()->isSectionAtomizableBySymbols(
- SD->getFragment()->getParent()->getSection()))
+ S.getData().getFragment()->getParent()->getSection()))
return nullptr;
// Otherwise, return the atom for the containing fragment.
- return SD->getFragment()->getAtom();
+ return S.getData().getFragment()->getAtom();
}
bool MCAssembler::evaluateFixup(const MCAsmLayout &Layout,
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=237803&r1=237802&r2=237803&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MachObjectWriter.cpp Wed May 20 11:02:11 2015
@@ -210,11 +210,11 @@ void AArch64MachObjectWriter::RecordRelo
} else if (Target.getSymB()) { // A - B + constant
const MCSymbol *A = &Target.getSymA()->getSymbol();
const MCSymbolData &A_SD = Asm.getSymbolData(*A);
- const MCSymbol *A_Base = Asm.getAtom(&A_SD);
+ const MCSymbol *A_Base = Asm.getAtom(*A);
const MCSymbol *B = &Target.getSymB()->getSymbol();
const MCSymbolData &B_SD = Asm.getSymbolData(*B);
- const MCSymbol *B_Base = Asm.getAtom(&B_SD);
+ const MCSymbol *B_Base = Asm.getAtom(*B);
// Check for "_foo at got - .", which comes through here as:
// Ltmp0:
@@ -296,7 +296,7 @@ void AArch64MachObjectWriter::RecordRelo
}
const MCSymbolData &SD = Asm.getSymbolData(*Symbol);
- const MCSymbol *Base = Asm.getAtom(&SD);
+ const MCSymbol *Base = Asm.getAtom(*Symbol);
// If the symbol is a variable and we weren't able to get a Base for it
// (i.e., it's not in the symbol table associated with a section) resolve
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=237803&r1=237802&r2=237803&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp Wed May 20 11:02:11 2015
@@ -143,13 +143,13 @@ void X86MachObjectWriter::RecordX86_64Re
if (A->isTemporary())
A = &Writer->findAliasedSymbol(*A);
const MCSymbolData &A_SD = Asm.getSymbolData(*A);
- const MCSymbol *A_Base = Asm.getAtom(&A_SD);
+ const MCSymbol *A_Base = Asm.getAtom(*A);
const MCSymbol *B = &Target.getSymB()->getSymbol();
if (B->isTemporary())
B = &Writer->findAliasedSymbol(*B);
const MCSymbolData &B_SD = Asm.getSymbolData(*B);
- const MCSymbol *B_Base = Asm.getAtom(&B_SD);
+ const MCSymbol *B_Base = Asm.getAtom(*B);
// Neither symbol can be modified.
if (Target.getSymA()->getKind() != MCSymbolRefExpr::VK_None ||
@@ -212,7 +212,7 @@ void X86MachObjectWriter::RecordX86_64Re
Asm.addLocalUsedInReloc(*Symbol);
}
const MCSymbolData &SD = Asm.getSymbolData(*Symbol);
- RelSymbol = Asm.getAtom(&SD);
+ RelSymbol = Asm.getAtom(*Symbol);
// Relocations inside debug sections always use local relocations when
// possible. This seems to be done because the debugger doesn't fully
More information about the llvm-commits
mailing list