Index: include/llvm/MC/MCELFStreamer.h =================================================================== --- include/llvm/MC/MCELFStreamer.h +++ include/llvm/MC/MCELFStreamer.h @@ -40,7 +40,8 @@ void InitSections(bool NoExecStack) override; void ChangeSection(MCSection *Section, const MCExpr *Subsection) override; - void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override; + void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc(), + const MCSubtargetInfo *STI = nullptr) override; void EmitLabel(MCSymbol *Symbol, SMLoc Loc, MCFragment *F) override; void EmitAssemblerFlag(MCAssemblerFlag Flag) override; void EmitThumbFunc(MCSymbol *Func) override; Index: include/llvm/MC/MCObjectStreamer.h =================================================================== --- include/llvm/MC/MCObjectStreamer.h +++ include/llvm/MC/MCObjectStreamer.h @@ -106,7 +106,8 @@ /// \name MCStreamer Interface /// @{ - void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override; + void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc(), + const MCSubtargetInfo *STI = nullptr) override; virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc, MCFragment *F); void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override; void EmitValueImpl(const MCExpr *Value, unsigned Size, Index: include/llvm/MC/MCStreamer.h =================================================================== --- include/llvm/MC/MCStreamer.h +++ include/llvm/MC/MCStreamer.h @@ -436,7 +436,8 @@ /// used in an assignment. // FIXME: These emission are non-const because we mutate the symbol to // add the section we're emitting it to later. - virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()); + virtual void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc(), + const MCSubtargetInfo *STI = nullptr); virtual void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol); Index: include/llvm/MC/MCWinCOFFStreamer.h =================================================================== --- include/llvm/MC/MCWinCOFFStreamer.h +++ include/llvm/MC/MCWinCOFFStreamer.h @@ -40,7 +40,8 @@ /// \{ void InitSections(bool NoExecStack) override; - void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override; + void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc(), + const MCSubtargetInfo *STI = nullptr) override; void EmitAssemblerFlag(MCAssemblerFlag Flag) override; void EmitThumbFunc(MCSymbol *Func) override; bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override; Index: lib/MC/MCAsmStreamer.cpp =================================================================== --- lib/MC/MCAsmStreamer.cpp +++ lib/MC/MCAsmStreamer.cpp @@ -137,7 +137,8 @@ const MCSymbol *Aliasee) override; void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) override; - void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override; + void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc(), + const MCSubtargetInfo *STI = nullptr) override; void EmitAssemblerFlag(MCAssemblerFlag Flag) override; void EmitLinkerOptions(ArrayRef Options) override; @@ -438,7 +439,8 @@ EmitEOL(); } -void MCAsmStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc) { +void MCAsmStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc, + const MCSubtargetInfo *STI) { MCStreamer::EmitLabel(Symbol, Loc); Symbol->print(OS, MAI); Index: lib/MC/MCELFStreamer.cpp =================================================================== --- lib/MC/MCELFStreamer.cpp +++ lib/MC/MCELFStreamer.cpp @@ -96,9 +96,10 @@ SwitchSection(Ctx.getAsmInfo()->getNonexecutableStackSection(Ctx)); } -void MCELFStreamer::EmitLabel(MCSymbol *S, SMLoc Loc) { +void MCELFStreamer::EmitLabel(MCSymbol *S, SMLoc Loc, + const MCSubtargetInfo *STI) { auto *Symbol = cast(S); - MCObjectStreamer::EmitLabel(Symbol, Loc); + MCObjectStreamer::EmitLabel(Symbol, Loc, STI); const MCSectionELF &Section = static_cast(*getCurrentSectionOnly()); Index: lib/MC/MCMachOStreamer.cpp =================================================================== --- lib/MC/MCMachOStreamer.cpp +++ lib/MC/MCMachOStreamer.cpp @@ -82,7 +82,8 @@ /// @{ void ChangeSection(MCSection *Sect, const MCExpr *Subsect) override; - void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override; + void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc(), + const MCSubtargetInfo *STI = nullptr) override; void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override; void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol) override; void EmitAssemblerFlag(MCAssemblerFlag Flag) override; @@ -178,7 +179,8 @@ EmitSymbolAttribute(EHSymbol, MCSA_PrivateExtern); } -void MCMachOStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc) { +void MCMachOStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc, + const MCSubtargetInfo *STI) { // We have to create a new fragment if this is an atom defining symbol, // fragments cannot span atoms. if (getAssembler().isSymbolLinkerVisible(*Symbol)) Index: lib/MC/MCObjectStreamer.cpp =================================================================== --- lib/MC/MCObjectStreamer.cpp +++ lib/MC/MCObjectStreamer.cpp @@ -229,7 +229,8 @@ EmitLabel(Frame.End); } -void MCObjectStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc) { +void MCObjectStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc, + const MCSubtargetInfo *STI) { MCStreamer::EmitLabel(Symbol, Loc); getAssembler().registerSymbol(*Symbol); @@ -238,8 +239,7 @@ // Otherwise queue the label and set its fragment pointer when we emit the // next fragment. auto *F = dyn_cast_or_null(getCurrentFragment()); - if (F && !(getAssembler().isBundlingEnabled() && - getAssembler().getRelaxAll())) { + if (F && CanReuseDataFragment(*F, getAssembler(), STI)) { Symbol->setFragment(F); Symbol->setOffset(F->getContents().size()); } else { Index: lib/MC/MCParser/AsmParser.cpp =================================================================== --- lib/MC/MCParser/AsmParser.cpp +++ lib/MC/MCParser/AsmParser.cpp @@ -1824,7 +1824,7 @@ // Emit the label. if (!getTargetParser().isParsingInlineAsm()) - Out.EmitLabel(Sym, IDLoc); + Out.EmitLabel(Sym, IDLoc, &getTargetParser().getSTI()); // If we are generating dwarf for assembly source files then gather the // info to make a dwarf label entry for this label if needed. Index: lib/MC/MCStreamer.cpp =================================================================== --- lib/MC/MCStreamer.cpp +++ lib/MC/MCStreamer.cpp @@ -343,7 +343,8 @@ SymbolOrdering[Symbol] = 1 + SymbolOrdering.size(); } -void MCStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc) { +void MCStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc, + const MCSubtargetInfo *STI) { Symbol->redefineIfPossible(); if (!Symbol->isUndefined() || Symbol->isVariable()) Index: lib/MC/MCWinCOFFStreamer.cpp =================================================================== --- lib/MC/MCWinCOFFStreamer.cpp +++ lib/MC/MCWinCOFFStreamer.cpp @@ -82,7 +82,8 @@ SwitchSection(getContext().getObjectFileInfo()->getTextSection()); } -void MCWinCOFFStreamer::EmitLabel(MCSymbol *S, SMLoc Loc) { +void MCWinCOFFStreamer::EmitLabel(MCSymbol *S, SMLoc Loc, + const MCSubtargetInfo * STI) { auto *Symbol = cast(S); MCObjectStreamer::EmitLabel(Symbol, Loc); } Index: lib/Object/RecordStreamer.h =================================================================== --- lib/Object/RecordStreamer.h +++ lib/Object/RecordStreamer.h @@ -47,7 +47,8 @@ RecordStreamer(MCContext &Context, const Module &M); void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override; - void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override; + void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc(), + const MCSubtargetInfo * STI = nullptr) override; void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override; bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override; void EmitZerofill(MCSection *Section, MCSymbol *Symbol, uint64_t Size, Index: lib/Object/RecordStreamer.cpp =================================================================== --- lib/Object/RecordStreamer.cpp +++ lib/Object/RecordStreamer.cpp @@ -86,7 +86,8 @@ MCStreamer::EmitInstruction(Inst, STI); } -void RecordStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc) { +void RecordStreamer::EmitLabel(MCSymbol *Symbol, SMLoc Loc, + const MCSubtargetInfo *STI) { MCStreamer::EmitLabel(Symbol); markDefined(*Symbol); } Index: lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp =================================================================== --- lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -1446,7 +1446,7 @@ MCSymbol *TmpLabel = Ctx.createTempSymbol( "pcrel_hi", /* AlwaysAddSuffix */ true, /* CanBeUnnamed */ false); - Out.EmitLabel(TmpLabel); + Out.EmitLabel(TmpLabel, IDLoc, &getSTI()); const RISCVMCExpr *SymbolHi = RISCVMCExpr::create(Symbol, VKHi, Ctx); emitToStreamer(