Skip to content

Commit 274370d

Browse files
committed
MCAsmInfo: Replace some Mach-O specific check with isMachO(). NFC
`HasMachO*` might lure contributors to add other object file format propery when it is not really necessary.
1 parent 89d0a5c commit 274370d

File tree

3 files changed

+4
-22
lines changed

3 files changed

+4
-22
lines changed

llvm/include/llvm/MC/MCAsmInfo.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,6 @@ class MCAsmInfo {
8585
/// Default is false.
8686
bool HasSubsectionsViaSymbols = false;
8787

88-
/// True if this is a MachO target that supports the macho-specific .zerofill
89-
/// directive for emitting BSS Symbols. Default is false.
90-
bool HasMachoZeroFillDirective = false;
91-
92-
/// True if this is a MachO target that supports the macho-specific .tbss
93-
/// directive for emitting thread local BSS Symbols. Default is false.
94-
bool HasMachoTBSSDirective = false;
95-
9688
/// True if this is a non-GNU COFF target. The COFF port of the GNU linker
9789
/// doesn't handle associative comdats in the way that we would like to use
9890
/// them.
@@ -401,10 +393,6 @@ class MCAsmInfo {
401393
/// undefined symbol. Defaults to nullptr.
402394
const char *WeakRefDirective = nullptr;
403395

404-
/// True if we have a directive to declare a global as being a weak defined
405-
/// symbol. Defaults to false.
406-
bool HasWeakDefDirective = false;
407-
408396
/// True if we have a directive to declare a global as being a weak defined
409397
/// symbol that can be hidden (unexported). Defaults to false.
410398
bool HasWeakDefCanBeHiddenDirective = false;
@@ -603,8 +591,7 @@ class MCAsmInfo {
603591

604592
// Accessors.
605593

606-
bool hasMachoZeroFillDirective() const { return HasMachoZeroFillDirective; }
607-
bool hasMachoTBSSDirective() const { return HasMachoTBSSDirective; }
594+
bool isMachO() const { return HasSubsectionsViaSymbols; }
608595
bool hasCOFFAssociativeComdats() const { return HasCOFFAssociativeComdats; }
609596
bool hasCOFFComdatConstants() const { return HasCOFFComdatConstants; }
610597
bool hasVisibilityOnlyWithLinkage() const {
@@ -730,7 +717,6 @@ class MCAsmInfo {
730717
bool hasAltEntry() const { return HasAltEntry; }
731718
const char *getWeakDirective() const { return WeakDirective; }
732719
const char *getWeakRefDirective() const { return WeakRefDirective; }
733-
bool hasWeakDefDirective() const { return HasWeakDefDirective; }
734720

735721
bool hasWeakDefCanBeHiddenDirective() const {
736722
return HasWeakDefCanBeHiddenDirective;

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ void AsmPrinter::emitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const {
636636
case GlobalValue::LinkOnceODRLinkage:
637637
case GlobalValue::WeakAnyLinkage:
638638
case GlobalValue::WeakODRLinkage:
639-
if (MAI->hasWeakDefDirective()) {
639+
if (MAI->isMachO()) {
640640
// .globl _foo
641641
OutStreamer->emitSymbolAttribute(GVSym, MCSA_Global);
642642

@@ -779,8 +779,7 @@ void AsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
779779

780780
// If we have a bss global going to a section that supports the
781781
// zerofill directive, do so here.
782-
if (GVKind.isBSS() && MAI->hasMachoZeroFillDirective() &&
783-
TheSection->isVirtualSection()) {
782+
if (GVKind.isBSS() && MAI->isMachO() && TheSection->isVirtualSection()) {
784783
if (Size == 0)
785784
Size = 1; // zerofill of 0 bytes is undefined.
786785
emitLinkage(GV, GVSym);
@@ -825,7 +824,7 @@ void AsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
825824
// TLOF class. This will also make it more obvious that stuff like
826825
// MCStreamer::EmitTBSSSymbol is macho specific and only called from macho
827826
// specific code.
828-
if (GVKind.isThreadLocal() && MAI->hasMachoTBSSDirective()) {
827+
if (GVKind.isThreadLocal() && MAI->isMachO()) {
829828
// Emit the .tbss symbol
830829
MCSymbol *MangSym =
831830
OutContext.getOrCreateSymbol(GVSym->getName() + Twine("$tlv$init"));

llvm/lib/MC/MCAsmInfoDarwin.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,9 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() {
6969
InlineAsmEnd = " InlineAsm End";
7070

7171
// Directives:
72-
HasWeakDefDirective = true;
7372
HasWeakDefCanBeHiddenDirective = true;
7473
WeakRefDirective = "\t.weak_reference ";
7574
ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
76-
HasMachoZeroFillDirective = true; // Uses .zerofill
77-
HasMachoTBSSDirective = true; // Uses .tbss
7875

7976
HiddenVisibilityAttr = MCSA_PrivateExtern;
8077
HiddenDeclarationVisibilityAttr = MCSA_Invalid;

0 commit comments

Comments
 (0)