diff options
author | Fangrui Song <i@maskray.me> | 2024-06-21 23:46:58 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2024-06-21 23:46:58 -0700 |
commit | 4684d0c0073669c1833be7bb127a149b1f7a5e65 (patch) | |
tree | cc0729fc113d9d8d956d01414ec0e10a735c49cf /llvm | |
parent | bfd263a34df5d3916eb8425bb070618324acabfa (diff) | |
download | llvm-4684d0c0073669c1833be7bb127a149b1f7a5e65.zip llvm-4684d0c0073669c1833be7bb127a149b1f7a5e65.tar.gz llvm-4684d0c0073669c1833be7bb127a149b1f7a5e65.tar.bz2 |
[MC] emitLabelAtPos: change parameter to MCDataFragment &. NFC
emitLabelAtPos is only called by ARMELFStreamer with MCDataFragment.
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/MC/MCELFStreamer.h | 2 | ||||
-rw-r--r-- | llvm/include/llvm/MC/MCObjectStreamer.h | 2 | ||||
-rw-r--r-- | llvm/include/llvm/MC/MCWasmStreamer.h | 2 | ||||
-rw-r--r-- | llvm/lib/MC/MCELFStreamer.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 15 | ||||
-rw-r--r-- | llvm/lib/MC/MCWasmStreamer.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp | 11 |
7 files changed, 13 insertions, 23 deletions
diff --git a/llvm/include/llvm/MC/MCELFStreamer.h b/llvm/include/llvm/MC/MCELFStreamer.h index 5f8ae5a..f96bddd7 100644 --- a/llvm/include/llvm/MC/MCELFStreamer.h +++ b/llvm/include/llvm/MC/MCELFStreamer.h @@ -48,7 +48,7 @@ public: 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 c0a337f..b78c4dd 100644 --- a/llvm/include/llvm/MC/MCObjectStreamer.h +++ b/llvm/include/llvm/MC/MCObjectStreamer.h @@ -130,7 +130,7 @@ public: /// @{ 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 f95628d..6c9687f 100644 --- a/llvm/include/llvm/MC/MCWasmStreamer.h +++ b/llvm/include/llvm/MC/MCWasmStreamer.h @@ -42,7 +42,7 @@ public: 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 8be3c0e..a478856 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 23e56a9..d138e69 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 8b59a6c34..4187de4 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 72d739c..655492f 100644 --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp @@ -555,7 +555,7 @@ public: 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 @@ private: 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 @@ private: 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 @@ private: 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); } |