MCSymbol: Remove setUndefined

The name is misleading, as setting Fragment to nullptr does not
necessarily make it undefined - common and equated symbols have
a nullptr fragment as well.
This commit is contained in:
Fangrui Song 2025-08-17 15:57:27 -07:00
parent bce14c69db
commit 34c7b7ccae
6 changed files with 4 additions and 9 deletions

View File

@ -2517,7 +2517,7 @@ BinaryContext::calculateEmittedSize(BinaryFunction &BF, bool FixBranches) {
// Clean-up the effect of the code emission.
for (const MCSymbol &Symbol : Assembler.symbols()) {
MCSymbol *MutableSymbol = const_cast<MCSymbol *>(&Symbol);
MutableSymbol->setUndefined();
MutableSymbol->setFragment(nullptr);
MutableSymbol->setIsRegistered(false);
}

View File

@ -662,7 +662,7 @@ Error CleanMCState::runOnFunctions(BinaryContext &BC) {
if (S->isDefined()) {
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: Symbol \"" << S->getName()
<< "\" is already defined\n");
const_cast<MCSymbol *>(S)->setUndefined();
const_cast<MCSymbol *>(S)->setFragment(nullptr);
}
if (S->isRegistered()) {
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: Symbol \"" << S->getName()

View File

@ -215,7 +215,7 @@ public:
Value = nullptr;
kind = Kind::Regular;
}
setUndefined();
Fragment = nullptr;
IsRedefinable = false;
}
}
@ -259,9 +259,6 @@ public:
Fragment = F;
}
/// Mark the symbol as undefined.
void setUndefined() { Fragment = nullptr; }
/// @}
/// \name Variable Symbols
/// @{

View File

@ -53,7 +53,7 @@ void MCSymbol::setVariableValue(const MCExpr *Value) {
"Cannot equate a common symbol");
this->Value = Value;
kind = Kind::Equated;
setUndefined();
Fragment = nullptr;
}
void MCSymbol::print(raw_ostream &OS, const MCAsmInfo *MAI) const {

View File

@ -220,7 +220,6 @@ static MCSymbolWasm *getOrCreateFunctionTableSymbol(MCContext &Ctx,
Sym = static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(Name));
Sym->setFunctionTable(Is64);
// The default function table is synthesized by the linker.
Sym->setUndefined();
}
return Sym;
}

View File

@ -113,7 +113,6 @@ MCSymbolWasm *WebAssembly::getOrCreateFunctionTableSymbol(
Sym = static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(Name));
Sym->setFunctionTable(is64);
// The default function table is synthesized by the linker.
Sym->setUndefined();
}
// MVP object files can't have symtab entries for tables.
if (!(Subtarget && Subtarget->hasCallIndirectOverlong()))