[llvm] 274370d - MCAsmInfo: Replace some Mach-O specific check with isMachO(). NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 13:51:17 PDT 2024
Author: Fangrui Song
Date: 2024-08-15T13:51:13-07:00
New Revision: 274370d60332e76c374fd7bf87ade16319c2782c
URL: https://github.com/llvm/llvm-project/commit/274370d60332e76c374fd7bf87ade16319c2782c
DIFF: https://github.com/llvm/llvm-project/commit/274370d60332e76c374fd7bf87ade16319c2782c.diff
LOG: 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.
Added:
Modified:
llvm/include/llvm/MC/MCAsmInfo.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/MC/MCAsmInfoDarwin.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCAsmInfo.h b/llvm/include/llvm/MC/MCAsmInfo.h
index 7c4f3b63756eae..dba5d97465af28 100644
--- a/llvm/include/llvm/MC/MCAsmInfo.h
+++ b/llvm/include/llvm/MC/MCAsmInfo.h
@@ -85,14 +85,6 @@ class MCAsmInfo {
/// Default is false.
bool HasSubsectionsViaSymbols = false;
- /// True if this is a MachO target that supports the macho-specific .zerofill
- /// directive for emitting BSS Symbols. Default is false.
- bool HasMachoZeroFillDirective = false;
-
- /// True if this is a MachO target that supports the macho-specific .tbss
- /// directive for emitting thread local BSS Symbols. Default is false.
- bool HasMachoTBSSDirective = false;
-
/// True if this is a non-GNU COFF target. The COFF port of the GNU linker
/// doesn't handle associative comdats in the way that we would like to use
/// them.
@@ -401,10 +393,6 @@ class MCAsmInfo {
/// undefined symbol. Defaults to nullptr.
const char *WeakRefDirective = nullptr;
- /// True if we have a directive to declare a global as being a weak defined
- /// symbol. Defaults to false.
- bool HasWeakDefDirective = false;
-
/// True if we have a directive to declare a global as being a weak defined
/// symbol that can be hidden (unexported). Defaults to false.
bool HasWeakDefCanBeHiddenDirective = false;
@@ -603,8 +591,7 @@ class MCAsmInfo {
// Accessors.
- bool hasMachoZeroFillDirective() const { return HasMachoZeroFillDirective; }
- bool hasMachoTBSSDirective() const { return HasMachoTBSSDirective; }
+ bool isMachO() const { return HasSubsectionsViaSymbols; }
bool hasCOFFAssociativeComdats() const { return HasCOFFAssociativeComdats; }
bool hasCOFFComdatConstants() const { return HasCOFFComdatConstants; }
bool hasVisibilityOnlyWithLinkage() const {
@@ -730,7 +717,6 @@ class MCAsmInfo {
bool hasAltEntry() const { return HasAltEntry; }
const char *getWeakDirective() const { return WeakDirective; }
const char *getWeakRefDirective() const { return WeakRefDirective; }
- bool hasWeakDefDirective() const { return HasWeakDefDirective; }
bool hasWeakDefCanBeHiddenDirective() const {
return HasWeakDefCanBeHiddenDirective;
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 7ab2f2c13def87..3c792fc89c9b6a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -636,7 +636,7 @@ void AsmPrinter::emitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const {
case GlobalValue::LinkOnceODRLinkage:
case GlobalValue::WeakAnyLinkage:
case GlobalValue::WeakODRLinkage:
- if (MAI->hasWeakDefDirective()) {
+ if (MAI->isMachO()) {
// .globl _foo
OutStreamer->emitSymbolAttribute(GVSym, MCSA_Global);
@@ -779,8 +779,7 @@ void AsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
// If we have a bss global going to a section that supports the
// zerofill directive, do so here.
- if (GVKind.isBSS() && MAI->hasMachoZeroFillDirective() &&
- TheSection->isVirtualSection()) {
+ if (GVKind.isBSS() && MAI->isMachO() && TheSection->isVirtualSection()) {
if (Size == 0)
Size = 1; // zerofill of 0 bytes is undefined.
emitLinkage(GV, GVSym);
@@ -825,7 +824,7 @@ void AsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
// TLOF class. This will also make it more obvious that stuff like
// MCStreamer::EmitTBSSSymbol is macho specific and only called from macho
// specific code.
- if (GVKind.isThreadLocal() && MAI->hasMachoTBSSDirective()) {
+ if (GVKind.isThreadLocal() && MAI->isMachO()) {
// Emit the .tbss symbol
MCSymbol *MangSym =
OutContext.getOrCreateSymbol(GVSym->getName() + Twine("$tlv$init"));
diff --git a/llvm/lib/MC/MCAsmInfoDarwin.cpp b/llvm/lib/MC/MCAsmInfoDarwin.cpp
index e218a42889de90..8d883e45a91cc6 100644
--- a/llvm/lib/MC/MCAsmInfoDarwin.cpp
+++ b/llvm/lib/MC/MCAsmInfoDarwin.cpp
@@ -69,12 +69,9 @@ MCAsmInfoDarwin::MCAsmInfoDarwin() {
InlineAsmEnd = " InlineAsm End";
// Directives:
- HasWeakDefDirective = true;
HasWeakDefCanBeHiddenDirective = true;
WeakRefDirective = "\t.weak_reference ";
ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
- HasMachoZeroFillDirective = true; // Uses .zerofill
- HasMachoTBSSDirective = true; // Uses .tbss
HiddenVisibilityAttr = MCSA_PrivateExtern;
HiddenDeclarationVisibilityAttr = MCSA_Invalid;
More information about the llvm-commits
mailing list