Skip to content

Commit bc0f696

Browse files
committed
MCSymbol: Replace isELF with MCContext::isELF
1 parent 72fbf10 commit bc0f696

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

llvm/include/llvm/MC/MCContext.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,8 @@ class MCContext {
390390
LLVM_ABI ~MCContext();
391391

392392
Environment getObjectFileType() const { return Env; }
393+
bool isELF() const { return Env == IsELF; }
394+
bool isMachO() const { return Env == IsMachO; }
393395

394396
const StringRef &getSwift5ReflectionSegmentName() const {
395397
return Swift5ReflectionSegmentName;

llvm/lib/MC/MCAsmBackend.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "llvm/MC/MCAsmBackend.h"
1010
#include "llvm/MC/MCAssembler.h"
11+
#include "llvm/MC/MCContext.h"
1112
#include "llvm/MC/MCDXContainerWriter.h"
1213
#include "llvm/MC/MCELFObjectWriter.h"
1314
#include "llvm/MC/MCGOFFObjectWriter.h"
@@ -122,14 +123,12 @@ void MCAsmBackend::maybeAddReloc(const MCFragment &F, const MCFixup &Fixup,
122123
}
123124

124125
bool MCAsmBackend::isDarwinCanonicalPersonality(const MCSymbol *Sym) const {
126+
assert(getContext().isMachO());
125127
// Consider a NULL personality (ie., no personality encoding) to be canonical
126128
// because it's always at 0.
127129
if (!Sym)
128130
return true;
129131

130-
if (!Sym->isMachO())
131-
llvm_unreachable("Expected MachO symbols only");
132-
133132
StringRef name = Sym->getName();
134133
// XXX: We intentionally leave out "___gcc_personality_v0" because, despite
135134
// being system-defined like these two, it is not very commonly-used.

llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static bool needsInterworking(const MCAssembler &Asm, const MCSymbol *Sym,
296296
unsigned FixupKind) {
297297
// Create relocations for unconditional branches to function symbols with
298298
// different execution mode in ELF binaries.
299-
if (!Sym || !Sym->isELF())
299+
if (!Sym || !Asm.getContext().isELF())
300300
return false;
301301
unsigned Type = cast<MCSymbolELF>(Sym)->getType();
302302
if ((Type == ELF::STT_FUNC || Type == ELF::STT_GNU_IFUNC)) {

llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2948,8 +2948,9 @@ bool MipsAsmParser::loadAndAddSymbolAddress(const MCExpr *SymExpr,
29482948
bool IsPtr64 = ABI.ArePtrs64bit();
29492949
bool IsLocalSym =
29502950
Res.getAddSym()->isInSection() || Res.getAddSym()->isTemporary() ||
2951-
(Res.getAddSym()->isELF() &&
2952-
cast<MCSymbolELF>(Res.getAddSym())->getBinding() == ELF::STB_LOCAL);
2951+
(getContext().isELF() &&
2952+
static_cast<const MCSymbolELF *>(Res.getAddSym())->getBinding() ==
2953+
ELF::STB_LOCAL);
29532954
// For O32, "$"-prefixed symbols are recognized as temporary while
29542955
// .L-prefixed symbols are not (PrivateGlobalPrefix is "$"). Recognize ".L"
29552956
// manually.

0 commit comments

Comments
 (0)