[llvm] 768ccf6 - MCSymbolRefExpr: Remove HasSubsectionsViaSymbolsBit
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 6 14:11:06 PDT 2025
Author: Fangrui Song
Date: 2025-04-06T14:11:01-07:00
New Revision: 768ccf69f3febe962e0d63dc87fbee31e59547a7
URL: https://github.com/llvm/llvm-project/commit/768ccf69f3febe962e0d63dc87fbee31e59547a7
DIFF: https://github.com/llvm/llvm-project/commit/768ccf69f3febe962e0d63dc87fbee31e59547a7.diff
LOG: MCSymbolRefExpr: Remove HasSubsectionsViaSymbolsBit
This information is only needed assembly time and we
can get it with Asm->getContext().getAsmInfo()->hasSubsectionsViaSymbols().
Added:
Modified:
llvm/include/llvm/MC/MCExpr.h
llvm/lib/MC/MCExpr.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCExpr.h b/llvm/include/llvm/MC/MCExpr.h
index 3d9113e92485d..f6377aa492c58 100644
--- a/llvm/include/llvm/MC/MCExpr.h
+++ b/llvm/include/llvm/MC/MCExpr.h
@@ -217,20 +217,6 @@ class MCSymbolRefExpr : public MCExpr {
/// The symbol being referenced.
const MCSymbol *Symbol;
- // Subclass data stores VariantKind in bits 0..15 and HasSubsectionsViaSymbols
- // in bit 16.
- static const unsigned VariantKindBits = 16;
- static const unsigned VariantKindMask = (1 << VariantKindBits) - 1;
-
- // FIXME: Remove this bit.
- static const unsigned HasSubsectionsViaSymbolsBit = 1 << VariantKindBits;
-
- static unsigned encodeSubclassData(VariantKind Kind,
- bool HasSubsectionsViaSymbols) {
- return (unsigned)Kind |
- (HasSubsectionsViaSymbols ? HasSubsectionsViaSymbolsBit : 0);
- }
-
explicit MCSymbolRefExpr(const MCSymbol *Symbol, VariantKind Kind,
const MCAsmInfo *MAI, SMLoc Loc = SMLoc());
@@ -259,16 +245,8 @@ class MCSymbolRefExpr : public MCExpr {
// Some targets encode the relocation specifier within SymA using
// MCSymbolRefExpr::SubclassData, which is copied to MCValue::Specifier,
// though this method is now deprecated.
- VariantKind getKind() const {
- return (VariantKind)(getSubclassData() & VariantKindMask);
- }
- uint16_t getSpecifier() const {
- return (getSubclassData() & VariantKindMask);
- }
-
- bool hasSubsectionsViaSymbols() const {
- return (getSubclassData() & HasSubsectionsViaSymbolsBit) != 0;
- }
+ VariantKind getKind() const { return VariantKind(getSubclassData()); }
+ uint16_t getSpecifier() const { return getSubclassData(); }
/// @}
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp
index 9fbe395e294b8..4c159feea48f8 100644
--- a/llvm/lib/MC/MCExpr.cpp
+++ b/llvm/lib/MC/MCExpr.cpp
@@ -235,9 +235,7 @@ const MCConstantExpr *MCConstantExpr::create(int64_t Value, MCContext &Ctx,
MCSymbolRefExpr::MCSymbolRefExpr(const MCSymbol *Symbol, VariantKind Kind,
const MCAsmInfo *MAI, SMLoc Loc)
- : MCExpr(MCExpr::SymbolRef, Loc,
- encodeSubclassData(Kind, MAI->hasSubsectionsViaSymbols())),
- Symbol(Symbol) {
+ : MCExpr(MCExpr::SymbolRef, Loc, Kind), Symbol(Symbol) {
assert(Symbol);
}
@@ -507,7 +505,8 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm,
// Evaluate recursively if this is a variable.
if (Sym.isVariable() && (Kind == MCSymbolRefExpr::VK_None || Layout) &&
canExpand(Sym, InSet)) {
- bool IsMachO = SRE->hasSubsectionsViaSymbols();
+ bool IsMachO =
+ Asm && Asm->getContext().getAsmInfo()->hasSubsectionsViaSymbols();
if (Sym.getVariableValue()->evaluateAsRelocatableImpl(Res, Asm,
InSet || IsMachO)) {
if (Kind != MCSymbolRefExpr::VK_None) {
More information about the llvm-commits
mailing list