[llvm] 7f017f0 - [MC] Drop unnecessary MCSymbol::setExternal calls for ELF
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jul 21 10:49:30 PDT 2024
Author: Fangrui Song
Date: 2024-07-21T10:49:25-07:00
New Revision: 7f017f0ab4fa9c46ca4c07320a61796b1ca64a63
URL: https://github.com/llvm/llvm-project/commit/7f017f0ab4fa9c46ca4c07320a61796b1ca64a63
DIFF: https://github.com/llvm/llvm-project/commit/7f017f0ab4fa9c46ca4c07320a61796b1ca64a63.diff
LOG: [MC] Drop unnecessary MCSymbol::setExternal calls for ELF
Similar to e4c360a897fe062914519d331e8f1e28b2b1fbfd (2020).
Added:
Modified:
llvm/include/llvm/MC/MCSymbol.h
llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCELFStreamer.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCSymbol.h b/llvm/include/llvm/MC/MCSymbol.h
index 5f06249b479eb..e0ba687feb080 100644
--- a/llvm/include/llvm/MC/MCSymbol.h
+++ b/llvm/include/llvm/MC/MCSymbol.h
@@ -403,6 +403,7 @@ class MCSymbol {
return Fragment;
}
+ // For ELF, use MCSymbolELF::setBinding instead.
bool isExternal() const { return IsExternal; }
void setExternal(bool Value) const { IsExternal = Value; }
diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
index 8754e551727ea..27751633017ca 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
@@ -276,7 +276,6 @@ class AArch64ELFStreamer : public MCELFStreamer {
emitLabel(Symbol);
Symbol->setType(ELF::STT_NOTYPE);
Symbol->setBinding(ELF::STB_LOCAL);
- Symbol->setExternal(false);
}
int64_t MappingSymbolCounter;
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp b/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
index c24d39b9e5fdd..45ec38cfb4dbc 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
@@ -96,7 +96,6 @@ bool AMDGPUMCInstLower::lowerOperand(const MachineOperand &MO,
}
case MachineOperand::MO_ExternalSymbol: {
MCSymbol *Sym = Ctx.getOrCreateSymbol(StringRef(MO.getSymbolName()));
- Sym->setExternal(true);
const MCSymbolRefExpr *Expr = MCSymbolRefExpr::create(Sym, Ctx);
MCOp = MCOperand::createExpr(Expr);
return true;
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
index 531031b580347..edc645103135b 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
@@ -828,10 +828,8 @@ void AMDGPUTargetELFStreamer::emitAMDGPULDS(MCSymbol *Symbol, unsigned Size,
MCSymbolELF *SymbolELF = cast<MCSymbolELF>(Symbol);
SymbolELF->setType(ELF::STT_OBJECT);
- if (!SymbolELF->isBindingSet()) {
+ if (!SymbolELF->isBindingSet())
SymbolELF->setBinding(ELF::STB_GLOBAL);
- SymbolELF->setExternal(true);
- }
if (SymbolELF->declareCommon(Size, Alignment, true)) {
report_fatal_error("Symbol: " + Symbol->getName() +
diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCELFStreamer.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCELFStreamer.cpp
index 22c82bf5ac1b4..ddc6898d53dbf 100644
--- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCELFStreamer.cpp
+++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCELFStreamer.cpp
@@ -97,10 +97,8 @@ void HexagonMCELFStreamer::HexagonMCEmitCommonSymbol(MCSymbol *Symbol,
StringRef sbss[4] = {".sbss.1", ".sbss.2", ".sbss.4", ".sbss.8"};
auto ELFSymbol = cast<MCSymbolELF>(Symbol);
- if (!ELFSymbol->isBindingSet()) {
+ if (!ELFSymbol->isBindingSet())
ELFSymbol->setBinding(ELF::STB_GLOBAL);
- ELFSymbol->setExternal(true);
- }
ELFSymbol->setType(ELF::STT_OBJECT);
More information about the llvm-commits
mailing list