mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-23 05:29:23 +00:00
MC: Simplify MCSymbolData initialization and remove MCSymbol pointer
Finally remove the `MCSymbolData::Symbol` pointer. It was still being used to track whether `MCSymbolData` had been initialized, but this is better tracked by the bitfield in `MCSymbol`. The only caller of `MCSymbolData::initialize()` was `MCAssembler`, which (other than `Symbol`) passed in all-0 values. Replace all that indirection with a default constructor. The main point is a cleanup (and there's more cleanup to do), but there are also some small memory savings. I measured ~989 MB down to ~975 MB, cutting a little over 1% off the top of `llc`. (I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`; see r236629 for details.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237873 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
0141c66026
commit
4652459f64
@ -1033,9 +1033,7 @@ public:
|
|||||||
return *Entry;
|
return *Entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasSymbolData(const MCSymbol &Symbol) const {
|
bool hasSymbolData(const MCSymbol &Symbol) const { return Symbol.hasData(); }
|
||||||
return Symbol.getUnsafeData().isInitialized();
|
|
||||||
}
|
|
||||||
|
|
||||||
MCSymbolData &getSymbolData(const MCSymbol &Symbol) {
|
MCSymbolData &getSymbolData(const MCSymbol &Symbol) {
|
||||||
return const_cast<MCSymbolData &>(
|
return const_cast<MCSymbolData &>(
|
||||||
@ -1051,7 +1049,7 @@ public:
|
|||||||
if (Created)
|
if (Created)
|
||||||
*Created = !hasSymbolData(Symbol);
|
*Created = !hasSymbolData(Symbol);
|
||||||
if (!hasSymbolData(Symbol)) {
|
if (!hasSymbolData(Symbol)) {
|
||||||
Symbol.getUnsafeData().initialize(Symbol, nullptr, 0);
|
Symbol.initializeData();
|
||||||
Symbols.push_back(&Symbol);
|
Symbols.push_back(&Symbol);
|
||||||
}
|
}
|
||||||
return Symbol.getData();
|
return Symbol.getData();
|
||||||
|
@ -29,8 +29,6 @@ class raw_ostream;
|
|||||||
|
|
||||||
// TODO: Merge completely with MCSymbol.
|
// TODO: Merge completely with MCSymbol.
|
||||||
class MCSymbolData {
|
class MCSymbolData {
|
||||||
const MCSymbol *Symbol;
|
|
||||||
|
|
||||||
/// Fragment - The fragment this symbol's value is relative to, if any. Also
|
/// Fragment - The fragment this symbol's value is relative to, if any. Also
|
||||||
/// stores if this symbol is visible outside this translation unit (bit 0) or
|
/// stores if this symbol is visible outside this translation unit (bit 0) or
|
||||||
/// if it is private extern (bit 1).
|
/// if it is private extern (bit 1).
|
||||||
@ -39,7 +37,7 @@ class MCSymbolData {
|
|||||||
union {
|
union {
|
||||||
/// Offset - The offset to apply to the fragment address to form this
|
/// Offset - The offset to apply to the fragment address to form this
|
||||||
/// symbol's value.
|
/// symbol's value.
|
||||||
uint64_t Offset;
|
uint64_t Offset = 0;
|
||||||
|
|
||||||
/// CommonSize - The size of the symbol, if it is 'common'.
|
/// CommonSize - The size of the symbol, if it is 'common'.
|
||||||
uint64_t CommonSize;
|
uint64_t CommonSize;
|
||||||
@ -47,30 +45,21 @@ class MCSymbolData {
|
|||||||
|
|
||||||
/// SymbolSize - An expression describing how to calculate the size of
|
/// SymbolSize - An expression describing how to calculate the size of
|
||||||
/// a symbol. If a symbol has no size this field will be NULL.
|
/// a symbol. If a symbol has no size this field will be NULL.
|
||||||
const MCExpr *SymbolSize;
|
const MCExpr *SymbolSize = nullptr;
|
||||||
|
|
||||||
/// CommonAlign - The alignment of the symbol, if it is 'common', or -1.
|
/// CommonAlign - The alignment of the symbol, if it is 'common', or -1.
|
||||||
//
|
//
|
||||||
// FIXME: Pack this in with other fields?
|
// FIXME: Pack this in with other fields?
|
||||||
unsigned CommonAlign;
|
unsigned CommonAlign = -1U;
|
||||||
|
|
||||||
/// Flags - The Flags field is used by object file implementations to store
|
/// Flags - The Flags field is used by object file implementations to store
|
||||||
/// additional per symbol information which is not easily classified.
|
/// additional per symbol information which is not easily classified.
|
||||||
uint32_t Flags;
|
uint32_t Flags = 0;
|
||||||
|
|
||||||
/// Index - Index field, for use by the object file implementation.
|
/// Index - Index field, for use by the object file implementation.
|
||||||
uint64_t Index;
|
uint64_t Index = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Only for use as sentinel.
|
|
||||||
MCSymbolData();
|
|
||||||
void initialize(const MCSymbol &Symbol, MCFragment *Fragment,
|
|
||||||
uint64_t Offset);
|
|
||||||
|
|
||||||
/// \name Accessors
|
|
||||||
/// @{
|
|
||||||
bool isInitialized() const { return Symbol; }
|
|
||||||
|
|
||||||
MCFragment *getFragment() const { return Fragment.getPointer(); }
|
MCFragment *getFragment() const { return Fragment.getPointer(); }
|
||||||
void setFragment(MCFragment *Value) { Fragment.setPointer(Value); }
|
void setFragment(MCFragment *Value) { Fragment.setPointer(Value); }
|
||||||
|
|
||||||
@ -185,6 +174,7 @@ class MCSymbol {
|
|||||||
/// IsUsed - True if this symbol has been used.
|
/// IsUsed - True if this symbol has been used.
|
||||||
mutable unsigned IsUsed : 1;
|
mutable unsigned IsUsed : 1;
|
||||||
|
|
||||||
|
mutable bool HasData : 1;
|
||||||
mutable MCSymbolData Data;
|
mutable MCSymbolData Data;
|
||||||
|
|
||||||
private: // MCContext creates and uniques these.
|
private: // MCContext creates and uniques these.
|
||||||
@ -192,7 +182,7 @@ private: // MCContext creates and uniques these.
|
|||||||
friend class MCContext;
|
friend class MCContext;
|
||||||
MCSymbol(StringRef name, bool isTemporary)
|
MCSymbol(StringRef name, bool isTemporary)
|
||||||
: Name(name), Section(nullptr), Value(nullptr), IsTemporary(isTemporary),
|
: Name(name), Section(nullptr), Value(nullptr), IsTemporary(isTemporary),
|
||||||
IsRedefinable(false), IsUsed(false) {}
|
IsRedefinable(false), IsUsed(false), HasData(false) {}
|
||||||
|
|
||||||
MCSymbol(const MCSymbol &) = delete;
|
MCSymbol(const MCSymbol &) = delete;
|
||||||
void operator=(const MCSymbol &) = delete;
|
void operator=(const MCSymbol &) = delete;
|
||||||
@ -206,16 +196,20 @@ public:
|
|||||||
/// getName - Get the symbol name.
|
/// getName - Get the symbol name.
|
||||||
StringRef getName() const { return Name; }
|
StringRef getName() const { return Name; }
|
||||||
|
|
||||||
|
bool hasData() const { return HasData; }
|
||||||
|
|
||||||
/// Get associated symbol data.
|
/// Get associated symbol data.
|
||||||
MCSymbolData &getData() const {
|
MCSymbolData &getData() const {
|
||||||
assert(Data.isInitialized() && "Missing symbol data!");
|
assert(HasData && "Missing symbol data!");
|
||||||
return Data;
|
return Data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get unsafe symbol data (even if uninitialized).
|
/// Initialize symbol data.
|
||||||
///
|
///
|
||||||
/// Don't assert on uninitialized data; just return it.
|
/// Nothing really to do here, but this is enables an assertion that \a
|
||||||
MCSymbolData &getUnsafeData() const { return Data; }
|
/// MCAssembler::getOrCreateSymbolData() has actually been called before
|
||||||
|
/// anyone calls \a getData().
|
||||||
|
void initializeData() const { HasData = true; }
|
||||||
|
|
||||||
/// \name Accessors
|
/// \name Accessors
|
||||||
/// @{
|
/// @{
|
||||||
|
@ -352,23 +352,6 @@ void MCSectionData::setBundleLockState(BundleLockStateType NewState) {
|
|||||||
|
|
||||||
/* *** */
|
/* *** */
|
||||||
|
|
||||||
MCSymbolData::MCSymbolData() : Symbol(nullptr) {}
|
|
||||||
|
|
||||||
void MCSymbolData::initialize(const MCSymbol &Symbol, MCFragment *Fragment,
|
|
||||||
uint64_t Offset) {
|
|
||||||
assert(!isInitialized() && "Expected uninitialized symbol");
|
|
||||||
|
|
||||||
this->Symbol = &Symbol;
|
|
||||||
this->Fragment.setPointer(Fragment);
|
|
||||||
this->Offset = Offset;
|
|
||||||
this->SymbolSize = nullptr;
|
|
||||||
this->CommonAlign = -1U;
|
|
||||||
this->Flags = 0;
|
|
||||||
this->Index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* *** */
|
|
||||||
|
|
||||||
MCAssembler::MCAssembler(MCContext &Context_, MCAsmBackend &Backend_,
|
MCAssembler::MCAssembler(MCContext &Context_, MCAsmBackend &Backend_,
|
||||||
MCCodeEmitter &Emitter_, MCObjectWriter &Writer_,
|
MCCodeEmitter &Emitter_, MCObjectWriter &Writer_,
|
||||||
raw_ostream &OS_)
|
raw_ostream &OS_)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user