Skip to content

Commit 34c7b7c

Browse files
committed
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.
1 parent bce14c6 commit 34c7b7c

File tree

6 files changed

+4
-9
lines changed

6 files changed

+4
-9
lines changed

bolt/lib/Core/BinaryContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2517,7 +2517,7 @@ BinaryContext::calculateEmittedSize(BinaryFunction &BF, bool FixBranches) {
25172517
// Clean-up the effect of the code emission.
25182518
for (const MCSymbol &Symbol : Assembler.symbols()) {
25192519
MCSymbol *MutableSymbol = const_cast<MCSymbol *>(&Symbol);
2520-
MutableSymbol->setUndefined();
2520+
MutableSymbol->setFragment(nullptr);
25212521
MutableSymbol->setIsRegistered(false);
25222522
}
25232523

bolt/lib/Passes/BinaryPasses.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ Error CleanMCState::runOnFunctions(BinaryContext &BC) {
662662
if (S->isDefined()) {
663663
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: Symbol \"" << S->getName()
664664
<< "\" is already defined\n");
665-
const_cast<MCSymbol *>(S)->setUndefined();
665+
const_cast<MCSymbol *>(S)->setFragment(nullptr);
666666
}
667667
if (S->isRegistered()) {
668668
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: Symbol \"" << S->getName()

llvm/include/llvm/MC/MCSymbol.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class MCSymbol {
215215
Value = nullptr;
216216
kind = Kind::Regular;
217217
}
218-
setUndefined();
218+
Fragment = nullptr;
219219
IsRedefinable = false;
220220
}
221221
}
@@ -259,9 +259,6 @@ class MCSymbol {
259259
Fragment = F;
260260
}
261261

262-
/// Mark the symbol as undefined.
263-
void setUndefined() { Fragment = nullptr; }
264-
265262
/// @}
266263
/// \name Variable Symbols
267264
/// @{

llvm/lib/MC/MCSymbol.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void MCSymbol::setVariableValue(const MCExpr *Value) {
5353
"Cannot equate a common symbol");
5454
this->Value = Value;
5555
kind = Kind::Equated;
56-
setUndefined();
56+
Fragment = nullptr;
5757
}
5858

5959
void MCSymbol::print(raw_ostream &OS, const MCAsmInfo *MAI) const {

llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ static MCSymbolWasm *getOrCreateFunctionTableSymbol(MCContext &Ctx,
220220
Sym = static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(Name));
221221
Sym->setFunctionTable(Is64);
222222
// The default function table is synthesized by the linker.
223-
Sym->setUndefined();
224223
}
225224
return Sym;
226225
}

llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ MCSymbolWasm *WebAssembly::getOrCreateFunctionTableSymbol(
113113
Sym = static_cast<MCSymbolWasm *>(Ctx.getOrCreateSymbol(Name));
114114
Sym->setFunctionTable(is64);
115115
// The default function table is synthesized by the linker.
116-
Sym->setUndefined();
117116
}
118117
// MVP object files can't have symtab entries for tables.
119118
if (!(Subtarget && Subtarget->hasCallIndirectOverlong()))

0 commit comments

Comments
 (0)