[llvm] 4684d0c - [MC] emitLabelAtPos: change parameter to MCDataFragment &. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 21 23:47:03 PDT 2024
Author: Fangrui Song
Date: 2024-06-21T23:46:58-07:00
New Revision: 4684d0c0073669c1833be7bb127a149b1f7a5e65
URL: https://github.com/llvm/llvm-project/commit/4684d0c0073669c1833be7bb127a149b1f7a5e65
DIFF: https://github.com/llvm/llvm-project/commit/4684d0c0073669c1833be7bb127a149b1f7a5e65.diff
LOG: [MC] emitLabelAtPos: change parameter to MCDataFragment &. NFC
emitLabelAtPos is only called by ARMELFStreamer with MCDataFragment.
Added:
Modified:
llvm/include/llvm/MC/MCELFStreamer.h
llvm/include/llvm/MC/MCObjectStreamer.h
llvm/include/llvm/MC/MCWasmStreamer.h
llvm/lib/MC/MCELFStreamer.cpp
llvm/lib/MC/MCObjectStreamer.cpp
llvm/lib/MC/MCWasmStreamer.cpp
llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCELFStreamer.h b/llvm/include/llvm/MC/MCELFStreamer.h
index 5f8ae5ace56fd..f96bddd736533 100644
--- a/llvm/include/llvm/MC/MCELFStreamer.h
+++ b/llvm/include/llvm/MC/MCELFStreamer.h
@@ -48,7 +48,7 @@ class MCELFStreamer : public MCObjectStreamer {
void initSections(bool NoExecStack, const MCSubtargetInfo &STI) override;
void changeSection(MCSection *Section, const MCExpr *Subsection) override;
void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
- void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCFragment *F,
+ void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCDataFragment &F,
uint64_t Offset) override;
void emitAssemblerFlag(MCAssemblerFlag Flag) override;
void emitThumbFunc(MCSymbol *Func) override;
diff --git a/llvm/include/llvm/MC/MCObjectStreamer.h b/llvm/include/llvm/MC/MCObjectStreamer.h
index c0a337f5ea45e..b78c4dd85d96e 100644
--- a/llvm/include/llvm/MC/MCObjectStreamer.h
+++ b/llvm/include/llvm/MC/MCObjectStreamer.h
@@ -130,7 +130,7 @@ class MCObjectStreamer : public MCStreamer {
/// @{
void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
- virtual void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCFragment *F,
+ virtual void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCDataFragment &F,
uint64_t Offset);
void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
void emitConditionalAssignment(MCSymbol *Symbol,
diff --git a/llvm/include/llvm/MC/MCWasmStreamer.h b/llvm/include/llvm/MC/MCWasmStreamer.h
index f95628d5e0e5f..6c9687f3ce442 100644
--- a/llvm/include/llvm/MC/MCWasmStreamer.h
+++ b/llvm/include/llvm/MC/MCWasmStreamer.h
@@ -42,7 +42,7 @@ class MCWasmStreamer : public MCObjectStreamer {
void changeSection(MCSection *Section, const MCExpr *Subsection) override;
void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
- void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCFragment *F,
+ void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCDataFragment &F,
uint64_t Offset) override;
void emitAssemblerFlag(MCAssemblerFlag Flag) override;
void emitThumbFunc(MCSymbol *Func) override;
diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp
index 8be3c0e721189..a478856692657 100644
--- a/llvm/lib/MC/MCELFStreamer.cpp
+++ b/llvm/lib/MC/MCELFStreamer.cpp
@@ -70,7 +70,7 @@ void MCELFStreamer::emitLabel(MCSymbol *S, SMLoc Loc) {
Symbol->setType(ELF::STT_TLS);
}
-void MCELFStreamer::emitLabelAtPos(MCSymbol *S, SMLoc Loc, MCFragment *F,
+void MCELFStreamer::emitLabelAtPos(MCSymbol *S, SMLoc Loc, MCDataFragment &F,
uint64_t Offset) {
auto *Symbol = cast<MCSymbolELF>(S);
MCObjectStreamer::emitLabelAtPos(Symbol, Loc, F, Offset);
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp
index 23e56a97f179f..d138e69a78540 100644
--- a/llvm/lib/MC/MCObjectStreamer.cpp
+++ b/llvm/lib/MC/MCObjectStreamer.cpp
@@ -319,21 +319,12 @@ void MCObjectStreamer::emitPendingAssignments(MCSymbol *Symbol) {
// Emit a label at a previously emitted fragment/offset position. This must be
// within the currently-active section.
void MCObjectStreamer::emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc,
- MCFragment *F, uint64_t Offset) {
- assert(F->getParent() == getCurrentSectionOnly());
-
+ MCDataFragment &F, uint64_t Offset) {
+ assert(F.getParent() == getCurrentSectionOnly());
MCStreamer::emitLabel(Symbol, Loc);
getAssembler().registerSymbol(*Symbol);
- auto *DF = dyn_cast_or_null<MCDataFragment>(F);
+ Symbol->setFragment(&F);
Symbol->setOffset(Offset);
- if (DF) {
- Symbol->setFragment(F);
- } else {
- assert(isa<MCDummyFragment>(F) &&
- "F must either be an MCDataFragment or the pending MCDummyFragment");
- assert(Offset == 0);
- addPendingLabel(Symbol);
- }
}
void MCObjectStreamer::emitULEB128Value(const MCExpr *Value) {
diff --git a/llvm/lib/MC/MCWasmStreamer.cpp b/llvm/lib/MC/MCWasmStreamer.cpp
index 8b59a6c3446f9..4187de4d5eb8e 100644
--- a/llvm/lib/MC/MCWasmStreamer.cpp
+++ b/llvm/lib/MC/MCWasmStreamer.cpp
@@ -49,7 +49,7 @@ void MCWasmStreamer::emitLabel(MCSymbol *S, SMLoc Loc) {
Symbol->setTLS();
}
-void MCWasmStreamer::emitLabelAtPos(MCSymbol *S, SMLoc Loc, MCFragment *F,
+void MCWasmStreamer::emitLabelAtPos(MCSymbol *S, SMLoc Loc, MCDataFragment &F,
uint64_t Offset) {
auto *Symbol = cast<MCSymbolWasm>(S);
MCObjectStreamer::emitLabelAtPos(Symbol, Loc, F, Offset);
diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
index 72d739cfca2a8..655492f245027 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
@@ -555,7 +555,7 @@ class ARMELFStreamer : public MCELFStreamer {
if (!LastEMSInfo->hasInfo())
return;
ElfMappingSymbolInfo *EMS = LastEMSInfo.get();
- EmitMappingSymbol("$d", SMLoc(), EMS->F, EMS->Offset);
+ emitMappingSymbol("$d", *EMS->F, EMS->Offset);
EMS->resetInfo();
}
@@ -630,7 +630,7 @@ class ARMELFStreamer : public MCELFStreamer {
Offset = 0;
}
bool hasInfo() { return F != nullptr; }
- MCFragment *F = nullptr;
+ MCDataFragment *F = nullptr;
uint64_t Offset = 0;
ElfMappingSymbol State = EMS_None;
};
@@ -645,7 +645,7 @@ class ARMELFStreamer : public MCELFStreamer {
auto *DF = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
if (!DF)
return;
- EMS->F = getCurrentFragment();
+ EMS->F = DF;
EMS->Offset = DF->getContents().size();
LastEMSInfo->State = EMS_Data;
return;
@@ -679,11 +679,10 @@ class ARMELFStreamer : public MCELFStreamer {
Symbol->setBinding(ELF::STB_LOCAL);
}
- void EmitMappingSymbol(StringRef Name, SMLoc Loc, MCFragment *F,
- uint64_t Offset) {
+ void emitMappingSymbol(StringRef Name, MCDataFragment &F, uint64_t Offset) {
auto *Symbol = cast<MCSymbolELF>(getContext().getOrCreateSymbol(
Name + "." + Twine(MappingSymbolCounter++)));
- emitLabelAtPos(Symbol, Loc, F, Offset);
+ emitLabelAtPos(Symbol, SMLoc(), F, Offset);
Symbol->setType(ELF::STT_NOTYPE);
Symbol->setBinding(ELF::STB_LOCAL);
}
More information about the llvm-commits
mailing list