diff options
author | Fangrui Song <i@maskray.me> | 2025-06-27 21:46:36 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2025-06-27 21:46:36 -0700 |
commit | 5aa3e6baa0b07951112cb8782a421c968b39dfb3 (patch) | |
tree | 50c31b57e98fd8771e6677b4c75aa959b1100af7 /llvm/lib/MC/MCExpr.cpp | |
parent | 109b7d965c58a89e1d01676125d53518e1913f96 (diff) | |
download | llvm-5aa3e6baa0b07951112cb8782a421c968b39dfb3.zip llvm-5aa3e6baa0b07951112cb8782a421c968b39dfb3.tar.gz llvm-5aa3e6baa0b07951112cb8782a421c968b39dfb3.tar.bz2 |
MC: Reduce MCSymbolRefExpr::VK_None uses
Diffstat (limited to 'llvm/lib/MC/MCExpr.cpp')
-rw-r--r-- | llvm/lib/MC/MCExpr.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp index 8919a26..aca3ec6 100644 --- a/llvm/lib/MC/MCExpr.cpp +++ b/llvm/lib/MC/MCExpr.cpp @@ -91,7 +91,7 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI, Sym.print(OS, MAI); const MCSymbolRefExpr::VariantKind Kind = SRE.getKind(); - if (Kind != MCSymbolRefExpr::VK_None) { + if (Kind) { if (!MAI) // should only be used by dump() OS << "@<variant " << Kind << '>'; else if (MAI->useParensForSpecifier()) // ARM @@ -487,8 +487,7 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, } return false; } - if (Sym.isVariable() && (Kind == MCSymbolRefExpr::VK_None || Layout) && - !Sym.isWeakExternal()) { + if (Sym.isVariable() && (Kind == 0 || Layout) && !Sym.isWeakExternal()) { Sym.setIsResolving(true); auto _ = make_scope_exit([&] { Sym.setIsResolving(false); }); bool IsMachO = @@ -502,7 +501,7 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, auto *A = Res.getAddSym(); auto *B = Res.getSubSym(); if (InSet || !(A && !B && A->isInSection())) { - if (Kind != MCSymbolRefExpr::VK_None) { + if (Kind) { if (Res.isAbsolute()) { Res = MCValue::get(&Sym, nullptr, 0, Kind); return true; @@ -510,8 +509,8 @@ bool MCExpr::evaluateAsRelocatableImpl(MCValue &Res, const MCAssembler *Asm, // If the reference has a variant kind, we can only handle expressions // which evaluate exactly to a single unadorned symbol. Attach the // original VariantKind to SymA of the result. - if (Res.getSpecifier() != MCSymbolRefExpr::VK_None || - !Res.getAddSym() || Res.getSubSym() || Res.getConstant()) + if (Res.getSpecifier() || !Res.getAddSym() || Res.getSubSym() || + Res.getConstant()) return false; Res.Specifier = Kind; } |