diff --git a/bolt/lib/Passes/AsmDump.cpp b/bolt/lib/Passes/AsmDump.cpp index 08191669e72f..ffc920af1c41 100644 --- a/bolt/lib/Passes/AsmDump.cpp +++ b/bolt/lib/Passes/AsmDump.cpp @@ -134,13 +134,14 @@ void dumpFunction(const BinaryFunction &BF) { std::unique_ptr<MCAsmBackend> MAB( BC.TheTarget->createMCAsmBackend(*BC.STI, *BC.MRI, MCTargetOptions())); int AsmPrinterVariant = BC.AsmInfo->getAssemblerDialect(); - MCInstPrinter *InstructionPrinter(BC.TheTarget->createMCInstPrinter( - *BC.TheTriple, AsmPrinterVariant, *BC.AsmInfo, *BC.MII, *BC.MRI)); + std::unique_ptr<MCInstPrinter> InstructionPrinter( + BC.TheTarget->createMCInstPrinter(*BC.TheTriple, AsmPrinterVariant, + *BC.AsmInfo, *BC.MII, *BC.MRI)); auto FOut = std::make_unique<formatted_raw_ostream>(OS); FOut->SetUnbuffered(); - std::unique_ptr<MCStreamer> AsmStreamer( - createAsmStreamer(*LocalCtx, std::move(FOut), InstructionPrinter, - std::move(MCEInstance.MCE), std::move(MAB))); + std::unique_ptr<MCStreamer> AsmStreamer(createAsmStreamer( + *LocalCtx, std::move(FOut), std::move(InstructionPrinter), + std::move(MCEInstance.MCE), std::move(MAB))); AsmStreamer->initSections(true, *BC.STI); std::unique_ptr<TargetMachine> TM(BC.TheTarget->createTargetMachine( *BC.TheTriple, "", "", TargetOptions(), std::nullopt)); diff --git a/clang/tools/driver/cc1as_main.cpp b/clang/tools/driver/cc1as_main.cpp index 7fe97cc6e6ac..b98fc5ead100 100644 --- a/clang/tools/driver/cc1as_main.cpp +++ b/clang/tools/driver/cc1as_main.cpp @@ -26,6 +26,7 @@ #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCCodeEmitter.h" #include "llvm/MC/MCContext.h" +#include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCObjectFileInfo.h" #include "llvm/MC/MCObjectWriter.h" @@ -541,8 +542,8 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts, // FIXME: There is a bit of code duplication with addPassesToEmitFile. if (Opts.OutputType == AssemblerInvocation::FT_Asm) { - MCInstPrinter *IP = TheTarget->createMCInstPrinter( - llvm::Triple(Opts.Triple), Opts.OutputAsmVariant, *MAI, *MCII, *MRI); + std::unique_ptr<MCInstPrinter> IP(TheTarget->createMCInstPrinter( + llvm::Triple(Opts.Triple), Opts.OutputAsmVariant, *MAI, *MCII, *MRI)); std::unique_ptr<MCCodeEmitter> CE; if (Opts.ShowEncoding) @@ -551,7 +552,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts, TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions)); auto FOut = std::make_unique<formatted_raw_ostream>(*Out); - Str.reset(TheTarget->createAsmStreamer(Ctx, std::move(FOut), IP, + Str.reset(TheTarget->createAsmStreamer(Ctx, std::move(FOut), std::move(IP), std::move(CE), std::move(MAB))); } else if (Opts.OutputType == AssemblerInvocation::FT_Null) { Str.reset(createNullStreamer(Ctx)); diff --git a/llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h b/llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h index 40740a3f2210..f0d658ffbef9 100644 --- a/llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h +++ b/llvm/include/llvm/DWARFLinker/Classic/DWARFStreamer.h @@ -286,7 +286,6 @@ private: MCAsmBackend *MAB; // Owned by MCStreamer std::unique_ptr<MCInstrInfo> MII; std::unique_ptr<MCSubtargetInfo> MSTI; - MCInstPrinter *MIP; // Owned by AsmPrinter MCCodeEmitter *MCE; // Owned by MCStreamer MCStreamer *MS; // Owned by AsmPrinter std::unique_ptr<TargetMachine> TM; diff --git a/llvm/include/llvm/MC/TargetRegistry.h b/llvm/include/llvm/MC/TargetRegistry.h index fd5c2acdd5da..f54f7ce75653 100644 --- a/llvm/include/llvm/MC/TargetRegistry.h +++ b/llvm/include/llvm/MC/TargetRegistry.h @@ -84,10 +84,11 @@ MCStreamer *createNullStreamer(MCContext &Ctx); /// /// \param ShowInst - Whether to show the MCInst representation inline with /// the assembly. -MCStreamer * -createAsmStreamer(MCContext &Ctx, std::unique_ptr<formatted_raw_ostream> OS, - MCInstPrinter *InstPrint, std::unique_ptr<MCCodeEmitter> &&CE, - std::unique_ptr<MCAsmBackend> &&TAB); +MCStreamer *createAsmStreamer(MCContext &Ctx, + std::unique_ptr<formatted_raw_ostream> OS, + std::unique_ptr<MCInstPrinter> InstPrint, + std::unique_ptr<MCCodeEmitter> CE, + std::unique_ptr<MCAsmBackend> TAB); MCStreamer *createELFStreamer(MCContext &Ctx, std::unique_ptr<MCAsmBackend> &&TAB, @@ -208,10 +209,10 @@ public: using AsmTargetStreamerCtorTy = MCTargetStreamer *(*)(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint); - using AsmStreamerCtorTy = - MCStreamer *(*)(MCContext &Ctx, std::unique_ptr<formatted_raw_ostream> OS, - MCInstPrinter *IP, std::unique_ptr<MCCodeEmitter> CE, - std::unique_ptr<MCAsmBackend> TAB); + using AsmStreamerCtorTy = MCStreamer + *(*)(MCContext & Ctx, std::unique_ptr<formatted_raw_ostream> OS, + std::unique_ptr<MCInstPrinter> IP, std::unique_ptr<MCCodeEmitter> CE, + std::unique_ptr<MCAsmBackend> TAB); using ObjectTargetStreamerCtorTy = MCTargetStreamer *(*)(MCStreamer &S, const MCSubtargetInfo &STI); using MCRelocationInfoCtorTy = MCRelocationInfo *(*)(const Triple &TT, @@ -552,7 +553,7 @@ public: MCStreamer *createAsmStreamer(MCContext &Ctx, std::unique_ptr<formatted_raw_ostream> OS, - MCInstPrinter *IP, + std::unique_ptr<MCInstPrinter> IP, std::unique_ptr<MCCodeEmitter> CE, std::unique_ptr<MCAsmBackend> TAB) const; diff --git a/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp b/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp index 32e77dbb1c22..dcadee6812bd 100644 --- a/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp +++ b/llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp @@ -162,16 +162,13 @@ CodeGenTargetMachineImpl::createMCStreamer(raw_pwrite_stream &Out, switch (FileType) { case CodeGenFileType::AssemblyFile: { - MCInstPrinter *InstPrinter = getTarget().createMCInstPrinter( + std::unique_ptr<MCInstPrinter> InstPrinter(getTarget().createMCInstPrinter( getTargetTriple(), Options.MCOptions.OutputAsmVariant.value_or(MAI.getAssemblerDialect()), - MAI, MII, MRI); - for (StringRef Opt : Options.MCOptions.InstPrinterOptions) { - if (!InstPrinter->applyTargetSpecificCLOption(Opt)) { - delete InstPrinter; + MAI, MII, MRI)); + for (StringRef Opt : Options.MCOptions.InstPrinterOptions) + if (!InstPrinter->applyTargetSpecificCLOption(Opt)) return createStringError("invalid InstPrinter option '" + Opt + "'"); - } - } // Create a code emitter if asked to show the encoding. std::unique_ptr<MCCodeEmitter> MCE; @@ -182,7 +179,8 @@ CodeGenTargetMachineImpl::createMCStreamer(raw_pwrite_stream &Out, getTarget().createMCAsmBackend(STI, MRI, Options.MCOptions)); auto FOut = std::make_unique<formatted_raw_ostream>(Out); MCStreamer *S = getTarget().createAsmStreamer( - Context, std::move(FOut), InstPrinter, std::move(MCE), std::move(MAB)); + Context, std::move(FOut), std::move(InstPrinter), std::move(MCE), + std::move(MAB)); AsmStreamer.reset(S); break; } diff --git a/llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp b/llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp index d4f62d351548..8485d3c9128e 100644 --- a/llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp +++ b/llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp @@ -14,6 +14,7 @@ #include "llvm/MC/MCAsmBackend.h" #include "llvm/MC/MCCodeEmitter.h" #include "llvm/MC/MCDwarf.h" +#include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCSection.h" #include "llvm/MC/MCStreamer.h" @@ -100,10 +101,10 @@ Error DwarfStreamer::init(Triple TheTriple, switch (OutFileType) { case DWARFLinker::OutputFileType::Assembly: { - MIP = TheTarget->createMCInstPrinter(TheTriple, MAI->getAssemblerDialect(), - *MAI, *MII, *MRI); + std::unique_ptr<MCInstPrinter> MIP(TheTarget->createMCInstPrinter( + TheTriple, MAI->getAssemblerDialect(), *MAI, *MII, *MRI)); MS = TheTarget->createAsmStreamer( - *MC, std::make_unique<formatted_raw_ostream>(OutFile), MIP, + *MC, std::make_unique<formatted_raw_ostream>(OutFile), std::move(MIP), std::unique_ptr<MCCodeEmitter>(MCE), std::unique_ptr<MCAsmBackend>(MAB)); break; diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFEmitterImpl.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFEmitterImpl.cpp index 4cd1875b37f5..379f60b0bfb9 100644 --- a/llvm/lib/DWARFLinker/Parallel/DWARFEmitterImpl.cpp +++ b/llvm/lib/DWARFLinker/Parallel/DWARFEmitterImpl.cpp @@ -10,6 +10,7 @@ #include "DWARFLinkerCompileUnit.h" #include "llvm/MC/MCAsmBackend.h" #include "llvm/MC/MCCodeEmitter.h" +#include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCObjectWriter.h" #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCTargetOptions.h" @@ -79,10 +80,10 @@ Error DwarfEmitterImpl::init(Triple TheTriple, switch (OutFileType) { case DWARFLinker::OutputFileType::Assembly: { - MIP = TheTarget->createMCInstPrinter(TheTriple, MAI->getAssemblerDialect(), - *MAI, *MII, *MRI); + std::unique_ptr<MCInstPrinter> MIP(TheTarget->createMCInstPrinter( + TheTriple, MAI->getAssemblerDialect(), *MAI, *MII, *MRI)); MS = TheTarget->createAsmStreamer( - *MC, std::make_unique<formatted_raw_ostream>(OutFile), MIP, + *MC, std::make_unique<formatted_raw_ostream>(OutFile), std::move(MIP), std::unique_ptr<MCCodeEmitter>(MCE), std::unique_ptr<MCAsmBackend>(MAB)); break; diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFEmitterImpl.h b/llvm/lib/DWARFLinker/Parallel/DWARFEmitterImpl.h index 71351f1d8c1c..bdebee42f396 100644 --- a/llvm/lib/DWARFLinker/Parallel/DWARFEmitterImpl.h +++ b/llvm/lib/DWARFLinker/Parallel/DWARFEmitterImpl.h @@ -16,6 +16,7 @@ #include "llvm/DWARFLinker/Parallel/DWARFLinker.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" +#include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCInstrInfo.h" #include "llvm/MC/MCObjectFileInfo.h" #include "llvm/MC/MCRegisterInfo.h" @@ -110,7 +111,7 @@ private: MCAsmBackend *MAB; // Owned by MCStreamer std::unique_ptr<MCInstrInfo> MII; std::unique_ptr<MCSubtargetInfo> MSTI; - MCInstPrinter *MIP; // Owned by AsmPrinter + std::unique_ptr<MCInstPrinter> MIP; // Owned by AsmPrinter MCCodeEmitter *MCE; // Owned by MCStreamer MCStreamer *MS; // Owned by AsmPrinter std::unique_ptr<TargetMachine> TM; diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp index fe6bb8c96514..9fb79d676f2c 100644 --- a/llvm/lib/MC/MCAsmStreamer.cpp +++ b/llvm/lib/MC/MCAsmStreamer.cpp @@ -74,10 +74,11 @@ class MCAsmStreamer final : public MCStreamer { public: MCAsmStreamer(MCContext &Context, std::unique_ptr<formatted_raw_ostream> os, - MCInstPrinter *printer, std::unique_ptr<MCCodeEmitter> emitter, + std::unique_ptr<MCInstPrinter> printer, + std::unique_ptr<MCCodeEmitter> emitter, std::unique_ptr<MCAsmBackend> asmbackend) : MCStreamer(Context), OSOwner(std::move(os)), OS(*OSOwner), - MAI(Context.getAsmInfo()), InstPrinter(printer), + MAI(Context.getAsmInfo()), InstPrinter(std::move(printer)), Assembler(std::make_unique<MCAssembler>( Context, std::move(asmbackend), std::move(emitter), (asmbackend) ? asmbackend->createObjectWriter(NullStream) @@ -2649,9 +2650,9 @@ void MCAsmStreamer::emitDwarfAdvanceLineAddr(int64_t LineDelta, MCStreamer *llvm::createAsmStreamer(MCContext &Context, std::unique_ptr<formatted_raw_ostream> OS, - MCInstPrinter *IP, - std::unique_ptr<MCCodeEmitter> &&CE, - std::unique_ptr<MCAsmBackend> &&MAB) { - return new MCAsmStreamer(Context, std::move(OS), IP, std::move(CE), + std::unique_ptr<MCInstPrinter> IP, + std::unique_ptr<MCCodeEmitter> CE, + std::unique_ptr<MCAsmBackend> MAB) { + return new MCAsmStreamer(Context, std::move(OS), std::move(IP), std::move(CE), std::move(MAB)); } diff --git a/llvm/lib/MC/TargetRegistry.cpp b/llvm/lib/MC/TargetRegistry.cpp index ca6ee76f5eb7..dde3612b9d18 100644 --- a/llvm/lib/MC/TargetRegistry.cpp +++ b/llvm/lib/MC/TargetRegistry.cpp @@ -12,6 +12,7 @@ #include "llvm/MC/MCAsmBackend.h" #include "llvm/MC/MCCodeEmitter.h" #include "llvm/MC/MCContext.h" +#include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCObjectStreamer.h" #include "llvm/MC/MCObjectWriter.h" #include "llvm/Support/raw_ostream.h" @@ -79,19 +80,20 @@ MCStreamer *Target::createMCObjectStreamer( MCStreamer *Target::createAsmStreamer(MCContext &Ctx, std::unique_ptr<formatted_raw_ostream> OS, - MCInstPrinter *IP, + std::unique_ptr<MCInstPrinter> IP, std::unique_ptr<MCCodeEmitter> CE, std::unique_ptr<MCAsmBackend> TAB) const { + MCInstPrinter *Printer = IP.get(); formatted_raw_ostream &OSRef = *OS; MCStreamer *S; if (AsmStreamerCtorFn) - S = AsmStreamerCtorFn(Ctx, std::move(OS), IP, std::move(CE), + S = AsmStreamerCtorFn(Ctx, std::move(OS), std::move(IP), std::move(CE), std::move(TAB)); else - S = llvm::createAsmStreamer(Ctx, std::move(OS), IP, std::move(CE), - std::move(TAB)); + S = llvm::createAsmStreamer(Ctx, std::move(OS), std::move(IP), + std::move(CE), std::move(TAB)); - createAsmTargetStreamer(*S, OSRef, IP); + createAsmTargetStreamer(*S, OSRef, Printer); return S; } diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZHLASMAsmStreamer.h b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZHLASMAsmStreamer.h index bf04eb850c40..edaaf984df65 100644 --- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZHLASMAsmStreamer.h +++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZHLASMAsmStreamer.h @@ -46,11 +46,11 @@ class SystemZHLASMAsmStreamer final : public MCStreamer { public: SystemZHLASMAsmStreamer(MCContext &Context, std::unique_ptr<formatted_raw_ostream> os, - MCInstPrinter *printer, + std::unique_ptr<MCInstPrinter> printer, std::unique_ptr<MCCodeEmitter> emitter, std::unique_ptr<MCAsmBackend> asmbackend) : MCStreamer(Context), FOSOwner(std::move(os)), FOS(*FOSOwner), OS(Str), - MAI(Context.getAsmInfo()), InstPrinter(printer), + MAI(Context.getAsmInfo()), InstPrinter(std::move(printer)), Assembler(std::make_unique<MCAssembler>( Context, std::move(asmbackend), std::move(emitter), (asmbackend) ? asmbackend->createObjectWriter(NullStream) diff --git a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp index c010c2c0025b..2bef87696a91 100644 --- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp +++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp @@ -192,19 +192,18 @@ static MCTargetStreamer *createAsmTargetStreamer(MCStreamer &S, return new SystemZTargetGNUStreamer(S, OS); } -static MCStreamer *createAsmStreamer(MCContext &Ctx, - std::unique_ptr<formatted_raw_ostream> OS, - MCInstPrinter *IP, - std::unique_ptr<MCCodeEmitter> CE, - std::unique_ptr<MCAsmBackend> TAB) { +static MCStreamer *createSystemZAsmStreamer( + MCContext &Ctx, std::unique_ptr<formatted_raw_ostream> OS, + std::unique_ptr<MCInstPrinter> IP, std::unique_ptr<MCCodeEmitter> CE, + std::unique_ptr<MCAsmBackend> TAB) { auto TT = Ctx.getTargetTriple(); if (TT.isOSzOS() && !GNUAsOnzOSCL) - return new SystemZHLASMAsmStreamer(Ctx, std::move(OS), IP, std::move(CE), - std::move(TAB)); + return new SystemZHLASMAsmStreamer(Ctx, std::move(OS), std::move(IP), + std::move(CE), std::move(TAB)); - return llvm::createAsmStreamer(Ctx, std::move(OS), IP, std::move(CE), - std::move(TAB)); + return llvm::createAsmStreamer(Ctx, std::move(OS), std::move(IP), + std::move(CE), std::move(TAB)); } static MCTargetStreamer * @@ -254,7 +253,8 @@ extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZTargetMC() { createSystemZMCInstPrinter); // Register the asm streamer. - TargetRegistry::RegisterAsmStreamer(getTheSystemZTarget(), createAsmStreamer); + TargetRegistry::RegisterAsmStreamer(getTheSystemZTarget(), + createSystemZAsmStreamer); // Register the asm target streamer. TargetRegistry::RegisterAsmTargetStreamer(getTheSystemZTarget(), diff --git a/llvm/test/tools/llvm-mc/disassembler-options.test b/llvm/test/tools/llvm-mc/disassembler-options.test index e53bfce9f47a..36da796fab4a 100644 --- a/llvm/test/tools/llvm-mc/disassembler-options.test +++ b/llvm/test/tools/llvm-mc/disassembler-options.test @@ -1,4 +1,3 @@ -# RUN: export LSAN_OPTIONS=detect_leaks=0 # RUN: not llvm-mc -M invalid /dev/null 2>&1 | FileCheck %s # CHECK: error: invalid InstPrinter option 'invalid' diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp index db2c6eeb2251..b59a54d8fbc8 100644 --- a/llvm/tools/llvm-mc/llvm-mc.cpp +++ b/llvm/tools/llvm-mc/llvm-mc.cpp @@ -519,10 +519,10 @@ int main(int argc, char **argv) { std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo()); assert(MCII && "Unable to create instruction info!"); - MCInstPrinter *IP = nullptr; + std::unique_ptr<MCInstPrinter> IP; if (FileType == OFT_AssemblyFile) { - IP = TheTarget->createMCInstPrinter(Triple(TripleName), OutputAsmVariant, - *MAI, *MCII, *MRI); + IP.reset(TheTarget->createMCInstPrinter( + Triple(TripleName), OutputAsmVariant, *MAI, *MCII, *MRI)); if (!IP) { WithColor::error() @@ -541,6 +541,17 @@ int main(int argc, char **argv) { // Set the display preference for hex vs. decimal immediates. IP->setPrintImmHex(PrintImmHex); + switch (Action) { + case AC_MDisassemble: + IP->setUseMarkup(true); + break; + case AC_CDisassemble: + IP->setUseColor(true); + break; + default: + break; + } + // Set up the AsmStreamer. std::unique_ptr<MCCodeEmitter> CE; if (ShowEncoding) @@ -549,7 +560,7 @@ int main(int argc, char **argv) { std::unique_ptr<MCAsmBackend> MAB( TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions)); auto FOut = std::make_unique<formatted_raw_ostream>(*OS); - Str.reset(TheTarget->createAsmStreamer(Ctx, std::move(FOut), IP, + Str.reset(TheTarget->createAsmStreamer(Ctx, std::move(FOut), std::move(IP), std::move(CE), std::move(MAB))); } else if (FileType == OFT_Null) { @@ -586,13 +597,7 @@ int main(int argc, char **argv) { *MCII, MCOptions); break; case AC_MDisassemble: - IP->setUseMarkup(true); - disassemble = true; - break; case AC_CDisassemble: - IP->setUseColor(true); - disassemble = true; - break; case AC_Disassemble: disassemble = true; break; diff --git a/llvm/tools/llvm-ml/llvm-ml.cpp b/llvm/tools/llvm-ml/llvm-ml.cpp index 1aa41096002e..c8e49edd34e0 100644 --- a/llvm/tools/llvm-ml/llvm-ml.cpp +++ b/llvm/tools/llvm-ml/llvm-ml.cpp @@ -363,13 +363,12 @@ int llvm_ml_main(int Argc, char **Argv, const llvm::ToolContext &) { std::unique_ptr<MCInstrInfo> MCII(TheTarget->createMCInstrInfo()); assert(MCII && "Unable to create instruction info!"); - MCInstPrinter *IP = nullptr; if (FileType == "s") { const bool OutputATTAsm = InputArgs.hasArg(OPT_output_att_asm); const unsigned OutputAsmVariant = OutputATTAsm ? 0U // ATT dialect : 1U; // Intel dialect - IP = TheTarget->createMCInstPrinter(TheTriple, OutputAsmVariant, *MAI, - *MCII, *MRI); + std::unique_ptr<MCInstPrinter> IP(TheTarget->createMCInstPrinter( + TheTriple, OutputAsmVariant, *MAI, *MCII, *MRI)); if (!IP) { WithColor::error() @@ -390,7 +389,7 @@ int llvm_ml_main(int Argc, char **Argv, const llvm::ToolContext &) { std::unique_ptr<MCAsmBackend> MAB( TheTarget->createMCAsmBackend(*STI, *MRI, MCOptions)); auto FOut = std::make_unique<formatted_raw_ostream>(*OS); - Str.reset(TheTarget->createAsmStreamer(Ctx, std::move(FOut), IP, + Str.reset(TheTarget->createAsmStreamer(Ctx, std::move(FOut), std::move(IP), std::move(CE), std::move(MAB))); } else if (FileType == "null") {