Index: include/llvm/MC/ConstantPools.h =================================================================== --- include/llvm/MC/ConstantPools.h +++ include/llvm/MC/ConstantPools.h @@ -27,6 +27,7 @@ class MCExpr; class MCSection; class MCStreamer; +class MCSubtargetInfo; class MCSymbol; class MCSymbolRefExpr; @@ -60,7 +61,7 @@ unsigned Size, SMLoc Loc); // Emit the contents of the constant pool using the provided streamer. - void emitEntries(MCStreamer &Streamer); + void emitEntries(MCStreamer &Streamer, const MCSubtargetInfo *STI); // Return true if the constant pool is empty bool empty(); Index: include/llvm/MC/MCELFStreamer.h =================================================================== --- include/llvm/MC/MCELFStreamer.h +++ include/llvm/MC/MCELFStreamer.h @@ -39,7 +39,7 @@ /// \name MCStreamer Interface /// @{ - void InitSections(bool NoExecStack) override; + 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 EmitLabel(MCSymbol *Symbol, SMLoc Loc, MCFragment *F) override; Index: include/llvm/MC/MCFragment.h =================================================================== --- include/llvm/MC/MCFragment.h +++ include/llvm/MC/MCFragment.h @@ -305,6 +305,10 @@ /// cannot be satisfied in this width then this fragment is ignored. unsigned MaxBytesToEmit; + /// MCSubtargetInfo - When emitting Nops some subtargets have specific + /// nop encodings. + const MCSubtargetInfo *STI; + public: MCAlignFragment(unsigned Alignment, int64_t Value, unsigned ValueSize, unsigned MaxBytesToEmit, MCSection *Sec = nullptr) @@ -324,10 +328,16 @@ unsigned getMaxBytesToEmit() const { return MaxBytesToEmit; } bool hasEmitNops() const { return EmitNops; } - void setEmitNops(bool Value) { EmitNops = Value; } + + const MCSubtargetInfo *getSubtargetInfo() const { return STI; } /// @} + void setEmitNops(const MCSubtargetInfo *STI) { + EmitNops = true; + this->STI = STI; + } + static bool classof(const MCFragment *F) { return F->getKind() == MCFragment::FT_Align; } Index: include/llvm/MC/MCObjectStreamer.h =================================================================== --- include/llvm/MC/MCObjectStreamer.h +++ include/llvm/MC/MCObjectStreamer.h @@ -120,7 +120,7 @@ void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0, unsigned ValueSize = 1, unsigned MaxBytesToEmit = 0) override; - void EmitCodeAlignment(unsigned ByteAlignment, + void EmitCodeAlignment(unsigned ByteAlignment, const MCSubtargetInfo *STI, unsigned MaxBytesToEmit = 0) override; void emitValueToOffset(const MCExpr *Offset, unsigned char Value, SMLoc Loc) override; Index: include/llvm/MC/MCSection.h =================================================================== --- include/llvm/MC/MCSection.h +++ include/llvm/MC/MCSection.h @@ -26,6 +26,7 @@ class MCAsmInfo; class MCContext; class MCExpr; +class MCSubtargetInfo; class MCSymbol; class raw_ostream; class Triple; @@ -167,6 +168,10 @@ MCSection::iterator getSubsectionInsertionPoint(unsigned Subsection); + // return the subtarget of the last fragment to have one, or nullptr + // if there if no fragment with a subtarget. + const MCSubtargetInfo *getLastSubtargetInfo() const; + void dump() const; virtual void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T, Index: include/llvm/MC/MCStreamer.h =================================================================== --- include/llvm/MC/MCStreamer.h +++ include/llvm/MC/MCStreamer.h @@ -408,7 +408,7 @@ } /// Create the default sections and set the initial one. - virtual void InitSections(bool NoExecStack); + virtual void InitSections(bool NoExecStack, const MCSubtargetInfo &STI); MCSymbol *endSection(MCSection *Section); @@ -727,10 +727,12 @@ /// /// \param ByteAlignment - The alignment to reach. This must be a power of /// two on some targets. + /// \param STI - The MCSubtargetInfo in operation when padding is emitted. /// \param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If /// the alignment cannot be reached in this many bytes, no bytes are /// emitted. virtual void EmitCodeAlignment(unsigned ByteAlignment, + const MCSubtargetInfo *STI, unsigned MaxBytesToEmit = 0); /// Emit some number of copies of \p Value until the byte offset \p Index: include/llvm/MC/MCWinCOFFStreamer.h =================================================================== --- include/llvm/MC/MCWinCOFFStreamer.h +++ include/llvm/MC/MCWinCOFFStreamer.h @@ -40,7 +40,7 @@ /// \name MCStreamer interface /// \{ - void InitSections(bool NoExecStack) override; + void InitSections(bool NoExecStack, const MCSubtargetInfo &STI) override; void EmitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override; void EmitAssemblerFlag(MCAssemblerFlag Flag) override; void EmitThumbFunc(MCSymbol *Func) override; Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp =================================================================== --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -248,7 +248,13 @@ const_cast(getObjFileLowering()) .Initialize(OutContext, TM); - OutStreamer->InitSections(false); + // We're at the module level. Construct MCSubtarget from the default CPU + // and target triple. + std::unique_ptr STI(TM.getTarget().createMCSubtargetInfo( + TM.getTargetTriple().str(), TM.getTargetCPU(), + TM.getTargetFeatureString())); + + OutStreamer->InitSections(false, OutContext.getSubtargetCopy(*STI)); // Emit the version-min deployment target directive if needed. // @@ -280,11 +286,6 @@ // Emit module-level inline asm if it exists. if (!M.getModuleInlineAsm().empty()) { - // We're at the module level. Construct MCSubtarget from the default CPU - // and target triple. - std::unique_ptr STI(TM.getTarget().createMCSubtargetInfo( - TM.getTargetTriple().str(), TM.getTargetCPU(), - TM.getTargetFeatureString())); OutStreamer->AddComment("Start of file scope inline assembly"); OutStreamer->AddBlankLine(); EmitInlineAsm(M.getModuleInlineAsm()+"\n", @@ -2018,8 +2019,15 @@ assert(NumBits < static_cast(std::numeric_limits::digits) && "undefined behavior"); - if (getCurrentSection()->getKind().isText()) - OutStreamer->EmitCodeAlignment(1u << NumBits); + + if (getCurrentSection()->getKind().isText()) { + const MCSubtargetInfo *STI = nullptr; + if (this->MF) + STI = &getSubtargetInfo(); + else + STI = TM.getMCSubtargetInfo(); + OutStreamer->EmitCodeAlignment(1u << NumBits, STI); + } else OutStreamer->EmitValueToAlignment(1u << NumBits); } @@ -2996,7 +3004,7 @@ // Each entry here will be 2 * word size aligned, as we're writing down two // pointers. This should work for both 32-bit and 64-bit platforms. OutStreamer->SwitchSection(FnSledIndex); - OutStreamer->EmitCodeAlignment(2 * WordSizeBytes); + OutStreamer->EmitCodeAlignment(2 * WordSizeBytes, &getSubtargetInfo()); OutStreamer->EmitSymbolValue(SledsStart, WordSizeBytes, false); OutStreamer->EmitSymbolValue(SledsEnd, WordSizeBytes, false); OutStreamer->SwitchSection(PrevSection); Index: lib/MC/ConstantPools.cpp =================================================================== --- lib/MC/ConstantPools.cpp +++ lib/MC/ConstantPools.cpp @@ -24,12 +24,13 @@ // ConstantPool implementation // // Emit the contents of the constant pool using the provided streamer. -void ConstantPool::emitEntries(MCStreamer &Streamer) { +void ConstantPool::emitEntries(MCStreamer &Streamer, + const MCSubtargetInfo *STI) { if (Entries.empty()) return; Streamer.EmitDataRegion(MCDR_DataRegion); for (const ConstantPoolEntry &Entry : Entries) { - Streamer.EmitCodeAlignment(Entry.Size); // align naturally + Streamer.EmitCodeAlignment(Entry.Size, STI); // align naturally Streamer.EmitLabel(Entry.Label); Streamer.EmitValue(Entry.Value, Entry.Size, Entry.Loc); } @@ -81,7 +82,7 @@ ConstantPool &CP) { if (!CP.empty()) { Streamer.SwitchSection(Section); - CP.emitEntries(Streamer); + CP.emitEntries(Streamer, Section->getLastSubtargetInfo()); } } Index: lib/MC/MCAsmStreamer.cpp =================================================================== --- lib/MC/MCAsmStreamer.cpp +++ lib/MC/MCAsmStreamer.cpp @@ -214,7 +214,7 @@ unsigned ValueSize = 1, unsigned MaxBytesToEmit = 0) override; - void EmitCodeAlignment(unsigned ByteAlignment, + void EmitCodeAlignment(unsigned ByteAlignment, const MCSubtargetInfo *STI, unsigned MaxBytesToEmit = 0) override; void emitValueToOffset(const MCExpr *Offset, @@ -1068,6 +1068,7 @@ } void MCAsmStreamer::EmitCodeAlignment(unsigned ByteAlignment, + const MCSubtargetInfo *STI, unsigned MaxBytesToEmit) { // Emit with a text fill value. EmitValueToAlignment(ByteAlignment, MAI->getTextAlignFillValue(), Index: lib/MC/MCELFStreamer.cpp =================================================================== --- lib/MC/MCELFStreamer.cpp +++ lib/MC/MCELFStreamer.cpp @@ -88,10 +88,10 @@ DF->getContents().append(EF->getContents().begin(), EF->getContents().end()); } -void MCELFStreamer::InitSections(bool NoExecStack) { +void MCELFStreamer::InitSections(bool NoExecStack, const MCSubtargetInfo &STI) { MCContext &Ctx = getContext(); SwitchSection(Ctx.getObjectFileInfo()->getTextSection()); - EmitCodeAlignment(4); + EmitCodeAlignment(4, &STI); if (NoExecStack) SwitchSection(Ctx.getAsmInfo()->getNonexecutableStackSection(Ctx)); Index: lib/MC/MCObjectStreamer.cpp =================================================================== --- lib/MC/MCObjectStreamer.cpp +++ lib/MC/MCObjectStreamer.cpp @@ -537,9 +537,10 @@ } void MCObjectStreamer::EmitCodeAlignment(unsigned ByteAlignment, + const MCSubtargetInfo *STI, unsigned MaxBytesToEmit) { EmitValueToAlignment(ByteAlignment, 0, 1, MaxBytesToEmit); - cast(getCurrentFragment())->setEmitNops(true); + cast(getCurrentFragment())->setEmitNops(STI); } void MCObjectStreamer::emitValueToOffset(const MCExpr *Offset, Index: lib/MC/MCParser/AsmParser.cpp =================================================================== --- lib/MC/MCParser/AsmParser.cpp +++ lib/MC/MCParser/AsmParser.cpp @@ -841,7 +841,7 @@ bool AsmParser::Run(bool NoInitialTextSection, bool NoFinalize) { // Create the initial section, if requested. if (!NoInitialTextSection) - Out.InitSections(false); + Out.InitSections(false, getTargetParser().getSTI()); // Prime the lexer. Lex(); @@ -950,7 +950,7 @@ bool AsmParser::checkForValidSection() { if (!ParsingInlineAsm && !getStreamer().getCurrentSectionOnly()) { - Out.InitSections(false); + Out.InitSections(false, getTargetParser().getSTI()); return Error(getTok().getLoc(), "expected section directive before assembly directive"); } @@ -3252,7 +3252,8 @@ bool UseCodeAlign = Section->UseCodeAlign(); if ((!HasFillExpr || Lexer.getMAI().getTextAlignFillValue() == FillExpr) && ValueSize == 1 && UseCodeAlign) { - getStreamer().EmitCodeAlignment(Alignment, MaxBytesToFill); + getStreamer().EmitCodeAlignment(Alignment, &getTargetParser().getSTI(), + MaxBytesToFill); } else { // FIXME: Target specific behavior about how the "extra" bytes are filled. getStreamer().EmitValueToAlignment(Alignment, FillExpr, ValueSize, Index: lib/MC/MCSection.cpp =================================================================== --- lib/MC/MCSection.cpp +++ lib/MC/MCSection.cpp @@ -86,6 +86,21 @@ return IP; } +const MCSubtargetInfo *MCSection::getLastSubtargetInfo() const { + for (auto Iter = rbegin(); Iter != rend(); ++Iter) { + const MCFragment &Frag = *Iter; + if (auto *FragWithSubtarget = dyn_cast(&Frag)) { + if (FragWithSubtarget->hasInstructions()) + return FragWithSubtarget->getSubtargetInfo(); + } else if (auto *FragWithSubtarget = dyn_cast(&Frag)) + return FragWithSubtarget->getSubtargetInfo(); + else if (auto *FragWithSubtarget = dyn_cast(&Frag)) + return FragWithSubtarget->getSubtargetInfo(); + // FIXME, will need MCPaddingFragment here as well. + } + return nullptr; +} + #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) LLVM_DUMP_METHOD void MCSection::dump() const { raw_ostream &OS = errs(); Index: lib/MC/MCStreamer.cpp =================================================================== --- lib/MC/MCStreamer.cpp +++ lib/MC/MCStreamer.cpp @@ -306,7 +306,7 @@ MCSymbol *EHSymbol) { } -void MCStreamer::InitSections(bool NoExecStack) { +void MCStreamer::InitSections(bool NoExecStack, const MCSubtargetInfo &STI) { SwitchSection(getContext().getObjectFileInfo()->getTextSection()); } @@ -961,6 +961,7 @@ unsigned ValueSize, unsigned MaxBytesToEmit) {} void MCStreamer::EmitCodeAlignment(unsigned ByteAlignment, + const MCSubtargetInfo *STI, unsigned MaxBytesToEmit) {} void MCStreamer::emitValueToOffset(const MCExpr *Offset, unsigned char Value, SMLoc Loc) {} Index: lib/MC/MCWinCOFFStreamer.cpp =================================================================== --- lib/MC/MCWinCOFFStreamer.cpp +++ lib/MC/MCWinCOFFStreamer.cpp @@ -67,18 +67,18 @@ DF->getContents().append(Code.begin(), Code.end()); } -void MCWinCOFFStreamer::InitSections(bool NoExecStack) { +void MCWinCOFFStreamer::InitSections(bool NoExecStack, const MCSubtargetInfo &STI) { // FIXME: this is identical to the ELF one. // This emulates the same behavior of GNU as. This makes it easier // to compare the output as the major sections are in the same order. SwitchSection(getContext().getObjectFileInfo()->getTextSection()); - EmitCodeAlignment(4); + EmitCodeAlignment(4, &STI); SwitchSection(getContext().getObjectFileInfo()->getDataSection()); - EmitCodeAlignment(4); + EmitCodeAlignment(4, &STI); SwitchSection(getContext().getObjectFileInfo()->getBSSSection()); - EmitCodeAlignment(4); + EmitCodeAlignment(4, &STI); SwitchSection(getContext().getObjectFileInfo()->getTextSection()); } Index: lib/Target/AArch64/AArch64AsmPrinter.cpp =================================================================== --- lib/Target/AArch64/AArch64AsmPrinter.cpp +++ lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -182,7 +182,7 @@ // ;DATA: higher 32 bits of the address of the trampoline // LDP X0, X30, [SP], #16 ; pop X0 and the link register from the stack // - OutStreamer->EmitCodeAlignment(4); + OutStreamer->EmitCodeAlignment(4, &getSubtargetInfo()); auto CurSled = OutContext.createTempSymbol("xray_sled_", true); OutStreamer->EmitLabel(CurSled); auto Target = OutContext.createTempSymbol(); Index: lib/Target/ARM/ARMAsmPrinter.cpp =================================================================== --- lib/Target/ARM/ARMAsmPrinter.cpp +++ lib/Target/ARM/ARMAsmPrinter.cpp @@ -1585,7 +1585,7 @@ // FIXME: Ideally we could vary the LDRB index based on the padding // between the sequence and jump table, however that relies on MCExprs // for load indexes which are currently not supported. - OutStreamer->EmitCodeAlignment(4); + OutStreamer->EmitCodeAlignment(4, &getSubtargetInfo()); EmitToStreamer(*OutStreamer, MCInstBuilder(ARM::tADDhirr) .addReg(Idx) .addReg(Idx) Index: lib/Target/ARM/ARMMCInstLower.cpp =================================================================== --- lib/Target/ARM/ARMMCInstLower.cpp +++ lib/Target/ARM/ARMMCInstLower.cpp @@ -195,7 +195,7 @@ // BLX ip // POP{ r0, lr } // - OutStreamer->EmitCodeAlignment(4); + OutStreamer->EmitCodeAlignment(4, &getSubtargetInfo()); auto CurSled = OutContext.createTempSymbol("xray_sled_", true); OutStreamer->EmitLabel(CurSled); auto Target = OutContext.createTempSymbol(); Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp =================================================================== --- lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -9947,13 +9947,13 @@ return true; if (!Section) { - getStreamer().InitSections(false); + getStreamer().InitSections(false, getSTI()); Section = getStreamer().getCurrentSectionOnly(); } assert(Section && "must have section to emit alignment"); if (Section->UseCodeAlign()) - getStreamer().EmitCodeAlignment(2); + getStreamer().EmitCodeAlignment(2, &getSTI()); else getStreamer().EmitValueToAlignment(2); @@ -10155,7 +10155,7 @@ const MCSection *Section = getStreamer().getCurrentSectionOnly(); assert(Section && "must have section to emit alignment"); if (Section->UseCodeAlign()) - getStreamer().EmitCodeAlignment(4, 0); + getStreamer().EmitCodeAlignment(4, &getSTI(), 0); else getStreamer().EmitValueToAlignment(4, 0, 1, 0); return false; Index: lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp =================================================================== --- lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp +++ lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp @@ -1210,7 +1210,7 @@ // Switch to .ARM.extab or .ARM.exidx section SwitchSection(EHSection); - EmitCodeAlignment(4); + EmitValueToAlignment(4, 0, 1, 0); } inline void ARMELFStreamer::SwitchToExTabSection(const MCSymbol &FnStart) { Index: lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp =================================================================== --- lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp +++ lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp @@ -1487,7 +1487,7 @@ MES->SwitchSection(mySection); unsigned byteSize = is32bit ? 4 : 8; - getStreamer().EmitCodeAlignment(byteSize, byteSize); + getStreamer().EmitCodeAlignment(byteSize, &getSTI(), byteSize); MCSymbol *Sym; Index: lib/Target/Hexagon/HexagonAsmPrinter.cpp =================================================================== --- lib/Target/Hexagon/HexagonAsmPrinter.cpp +++ lib/Target/Hexagon/HexagonAsmPrinter.cpp @@ -187,7 +187,7 @@ static MCSymbol *smallData(AsmPrinter &AP, const MachineInstr &MI, MCStreamer &OutStreamer, const MCOperand &Imm, - int AlignSize) { + int AlignSize, const MCSubtargetInfo& STI) { MCSymbol *Sym; int64_t Value; if (Imm.getExpr()->evaluateAsAbsolute(Value)) { @@ -217,7 +217,7 @@ OutStreamer.EmitLabel(Sym); OutStreamer.EmitSymbolAttribute(Sym, MCSA_Global); OutStreamer.EmitIntValue(Value, AlignSize); - OutStreamer.EmitCodeAlignment(AlignSize); + OutStreamer.EmitCodeAlignment(AlignSize, &STI); } } else { assert(Imm.isExpr() && "Expected expression and found none"); @@ -245,7 +245,7 @@ OutStreamer.EmitLabel(Sym); OutStreamer.EmitSymbolAttribute(Sym, MCSA_Local); OutStreamer.EmitValue(Imm.getExpr(), AlignSize); - OutStreamer.EmitCodeAlignment(AlignSize); + OutStreamer.EmitCodeAlignment(AlignSize, &STI); } } return Sym; @@ -335,8 +335,7 @@ if (!OutStreamer->hasRawTextSupport()) { const MCOperand &Imm = MappedInst.getOperand(1); MCSectionSubPair Current = OutStreamer->getCurrentSection(); - - MCSymbol *Sym = smallData(*this, MI, *OutStreamer, Imm, 8); + MCSymbol *Sym = smallData(*this, MI, *OutStreamer, Imm, 8, getSubtargetInfo()); OutStreamer->SwitchSection(Current.first, Current.second); MCInst TmpInst; @@ -353,7 +352,7 @@ if (!OutStreamer->hasRawTextSupport()) { MCOperand &Imm = MappedInst.getOperand(1); MCSectionSubPair Current = OutStreamer->getCurrentSection(); - MCSymbol *Sym = smallData(*this, MI, *OutStreamer, Imm, 4); + MCSymbol *Sym = smallData(*this, MI, *OutStreamer, Imm, 4, getSubtargetInfo()); OutStreamer->SwitchSection(Current.first, Current.second); MCInst TmpInst; MCOperand &Reg = MappedInst.getOperand(0); Index: lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp +++ lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp @@ -879,8 +879,14 @@ unsigned Alignment = Section.getAlignment(); if (Alignment) { OS.SwitchSection(&Section); - if (Section.UseCodeAlign()) - OS.EmitCodeAlignment(Alignment, Alignment); + if (Section.UseCodeAlign()) { + // Find the most appropriate SubtargetInfo for the padding. + const MCSubtargetInfo *LastSTI = Section.getLastSubtargetInfo(); + if (LastSTI == nullptr) + // There is a global one registered in MipsTargetELFStreamer. + LastSTI = &STI; + OS.EmitCodeAlignment(Alignment, LastSTI, Alignment); + } else OS.EmitValueToAlignment(Alignment, 0, 1, Alignment); } Index: lib/Target/Mips/MipsAsmPrinter.cpp =================================================================== --- lib/Target/Mips/MipsAsmPrinter.cpp +++ lib/Target/Mips/MipsAsmPrinter.cpp @@ -1151,7 +1151,7 @@ // LD RA, 8(SP) // DADDIU SP, SP, 16 // - OutStreamer->EmitCodeAlignment(4); + OutStreamer->EmitCodeAlignment(4, &getSubtargetInfo()); auto CurSled = OutContext.createTempSymbol("xray_sled_", true); OutStreamer->EmitLabel(CurSled); auto Target = OutContext.createTempSymbol(); Index: lib/Target/PowerPC/PPCAsmPrinter.cpp =================================================================== --- lib/Target/PowerPC/PPCAsmPrinter.cpp +++ lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -1185,7 +1185,7 @@ // // Update compiler-rt/lib/xray/xray_powerpc64.cc accordingly when number // of instructions change. - OutStreamer->EmitCodeAlignment(8); + OutStreamer->EmitCodeAlignment(8, &getSubtargetInfo()); MCSymbol *BeginOfSled = OutContext.createTempSymbol(); OutStreamer->EmitLabel(BeginOfSled); EmitToStreamer(*OutStreamer, RetInst); Index: lib/Target/X86/AsmParser/X86AsmParser.cpp =================================================================== --- lib/Target/X86/AsmParser/X86AsmParser.cpp +++ lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -3209,11 +3209,11 @@ const MCSection *Section = getStreamer().getCurrentSectionOnly(); if (!Section) { - getStreamer().InitSections(false); + getStreamer().InitSections(false, getSTI()); Section = getStreamer().getCurrentSectionOnly(); } if (Section->UseCodeAlign()) - getStreamer().EmitCodeAlignment(2, 0); + getStreamer().EmitCodeAlignment(2, &getSTI(), 0); else getStreamer().EmitValueToAlignment(2, 0, 1, 0); return false; Index: lib/Target/X86/X86MCInstLower.cpp =================================================================== --- lib/Target/X86/X86MCInstLower.cpp +++ lib/Target/X86/X86MCInstLower.cpp @@ -1406,7 +1406,7 @@ // First we emit the label and the jump. auto CurSled = OutContext.createTempSymbol("xray_event_sled_", true); OutStreamer->AddComment("# XRay Custom Event Log"); - OutStreamer->EmitCodeAlignment(2); + OutStreamer->EmitCodeAlignment(2, &getSubtargetInfo()); OutStreamer->EmitLabel(CurSled); // Use a two-byte `jmp`. This version of JMP takes an 8-bit relative offset as @@ -1497,7 +1497,7 @@ // First we emit the label and the jump. auto CurSled = OutContext.createTempSymbol("xray_typed_event_sled_", true); OutStreamer->AddComment("# XRay Typed Event Log"); - OutStreamer->EmitCodeAlignment(2); + OutStreamer->EmitCodeAlignment(2, &getSubtargetInfo()); OutStreamer->EmitLabel(CurSled); // Use a two-byte `jmp`. This version of JMP takes an 8-bit relative offset as @@ -1583,7 +1583,7 @@ // call // 5 bytes // auto CurSled = OutContext.createTempSymbol("xray_sled_", true); - OutStreamer->EmitCodeAlignment(2); + OutStreamer->EmitCodeAlignment(2, &getSubtargetInfo()); OutStreamer->EmitLabel(CurSled); // Use a two-byte `jmp`. This version of JMP takes an 8-bit relative offset as @@ -1611,7 +1611,7 @@ // // This just makes sure that the alignment for the next instruction is 2. auto CurSled = OutContext.createTempSymbol("xray_sled_", true); - OutStreamer->EmitCodeAlignment(2); + OutStreamer->EmitCodeAlignment(2, &getSubtargetInfo()); OutStreamer->EmitLabel(CurSled); unsigned OpCode = MI.getOperand(0).getImm(); MCInst Ret; @@ -1633,7 +1633,7 @@ // the PATCHABLE_FUNCTION_ENTER case, followed by the lowering of the actual // tail call much like how we have it in PATCHABLE_RET. auto CurSled = OutContext.createTempSymbol("xray_sled_", true); - OutStreamer->EmitCodeAlignment(2); + OutStreamer->EmitCodeAlignment(2, &getSubtargetInfo()); OutStreamer->EmitLabel(CurSled); auto Target = OutContext.createTempSymbol(); Index: tools/llvm-mc/Disassembler.cpp =================================================================== --- tools/llvm-mc/Disassembler.cpp +++ tools/llvm-mc/Disassembler.cpp @@ -161,7 +161,7 @@ } // Set up initial section manually here - Streamer.InitSections(false); + Streamer.InitSections(false, STI); bool ErrorOccurred = false; Index: tools/llvm-mc/llvm-mc.cpp =================================================================== --- tools/llvm-mc/llvm-mc.cpp +++ tools/llvm-mc/llvm-mc.cpp @@ -486,7 +486,7 @@ MCOptions.MCIncrementalLinkerCompatible, /*DWARFMustBeAtTheEnd*/ false)); if (NoExecStack) - Str->InitSections(true); + Str->InitSections(true, *STI); } // Use Assembler information for parsing.