Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions bolt/include/bolt/Core/BinaryContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1545,8 +1545,7 @@ class BinaryContext {
/// won't be used in the main code emitter.
IndependentCodeEmitter createIndependentMCCodeEmitter() const {
IndependentCodeEmitter MCEInstance;
MCEInstance.LocalCtx.reset(
new MCContext(*TheTriple, *AsmInfo, MRI.get(), STI.get()));
MCEInstance.LocalCtx.reset(new MCContext(*TheTriple, *AsmInfo, *MRI, *STI));
MCEInstance.LocalMOFI.reset(
TheTarget->createMCObjectFileInfo(*MCEInstance.LocalCtx,
/*PIC=*/!HasFixedLoadAddress));
Expand Down
2 changes: 1 addition & 1 deletion bolt/lib/Core/BinaryContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Expected<std::unique_ptr<BinaryContext>> BinaryContext::createBinaryContext(
Twine("BOLT-ERROR: no instruction info for target ", TripleName));

std::unique_ptr<MCContext> Ctx(
new MCContext(TheTriple, *AsmInfo, MRI.get(), STI.get()));
new MCContext(TheTriple, *AsmInfo, *MRI, *STI));
std::unique_ptr<MCObjectFileInfo> MOFI(
TheTarget->createMCObjectFileInfo(*Ctx, IsPIC));
Ctx->setObjectFileInfo(MOFI.get());
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Parse/ParseStmtAsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
}

llvm::SourceMgr TempSrcMgr;
llvm::MCContext Ctx(TheTriple, *MAI, MRI.get(), STI.get(), &TempSrcMgr);
llvm::MCContext Ctx(TheTriple, *MAI, *MRI, *STI, &TempSrcMgr);
std::unique_ptr<llvm::MCObjectFileInfo> MOFI(
TheTarget->createMCObjectFileInfo(Ctx, /*PIC=*/false));
Ctx.setObjectFileInfo(MOFI.get());
Expand Down
8 changes: 4 additions & 4 deletions clang/tools/driver/cc1_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ static int PrintSupportedExtensions(std::string TargetStr) {
std::unique_ptr<llvm::TargetMachine> TheTargetMachine(
TheTarget->createTargetMachine(Triple, "", "", Options, std::nullopt));
const llvm::Triple &MachineTriple = TheTargetMachine->getTargetTriple();
const llvm::MCSubtargetInfo *MCInfo = TheTargetMachine->getMCSubtargetInfo();
const llvm::MCSubtargetInfo &MCInfo = TheTargetMachine->getMCSubtargetInfo();
const llvm::ArrayRef<llvm::SubtargetFeatureKV> Features =
MCInfo->getAllProcessorFeatures();
MCInfo.getAllProcessorFeatures();

llvm::StringMap<llvm::StringRef> DescMap;
for (const llvm::SubtargetFeatureKV &feature : Features)
Expand Down Expand Up @@ -187,13 +187,13 @@ static int PrintEnabledExtensions(const TargetOptions& TargetOpts) {
TheTarget->createTargetMachine(Triple, TargetOpts.CPU, FeaturesStr,
BackendOptions, std::nullopt));
const llvm::Triple &MachineTriple = TheTargetMachine->getTargetTriple();
const llvm::MCSubtargetInfo *MCInfo = TheTargetMachine->getMCSubtargetInfo();
const llvm::MCSubtargetInfo &MCInfo = TheTargetMachine->getMCSubtargetInfo();

// Extract the feature names that are enabled for the given target.
// We do that by capturing the key from the set of SubtargetFeatureKV entries
// provided by MCSubtargetInfo, which match the '-target-feature' values.
const std::vector<llvm::SubtargetFeatureKV> Features =
MCInfo->getEnabledProcessorFeatures();
MCInfo.getEnabledProcessorFeatures();
std::set<llvm::StringRef> EnabledFeatureNames;
for (const llvm::SubtargetFeatureKV &feature : Features)
EnabledFeatureNames.insert(feature.Key);
Expand Down
2 changes: 1 addition & 1 deletion clang/tools/driver/cc1as_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
<< Opts.CPU << FS.empty() << FS;
}

MCContext Ctx(Triple(Opts.Triple), *MAI, MRI.get(), STI.get(), &SrcMgr);
MCContext Ctx(Triple(Opts.Triple), *MAI, *MRI, *STI, &SrcMgr);

bool PIC = false;
if (Opts.RelocationModel == "static") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1283,9 +1283,8 @@ DisassemblerLLVMC::MCDisasmInstance::Create(const char *triple_name,
if (!asm_info_up)
return Instance();

std::unique_ptr<llvm::MCContext> context_up(
new llvm::MCContext(llvm::Triple(triple), *asm_info_up, reg_info_up.get(),
subtarget_info_up.get()));
std::unique_ptr<llvm::MCContext> context_up(new llvm::MCContext(
llvm::Triple(triple), *asm_info_up, *reg_info_up, *subtarget_info_up));
if (!context_up)
return Instance();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ EmulateInstructionMIPS::EmulateInstructionMIPS(
m_subtype_info.reset(target->createMCSubtargetInfo(triple, cpu, features));
assert(m_asm_info.get() && m_subtype_info.get());

m_context = std::make_unique<llvm::MCContext>(
triple, *m_asm_info, m_reg_info.get(), m_subtype_info.get());
m_context = std::make_unique<llvm::MCContext>(triple, *m_asm_info,
*m_reg_info, *m_subtype_info);
assert(m_context.get());

m_disasm.reset(target->createMCDisassembler(*m_subtype_info, *m_context));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ EmulateInstructionMIPS64::EmulateInstructionMIPS64(
m_subtype_info.reset(target->createMCSubtargetInfo(triple, cpu, features));
assert(m_asm_info.get() && m_subtype_info.get());

m_context = std::make_unique<llvm::MCContext>(
triple, *m_asm_info, m_reg_info.get(), m_subtype_info.get());
m_context = std::make_unique<llvm::MCContext>(triple, *m_asm_info,
*m_reg_info, *m_subtype_info);
assert(m_context.get());

m_disasm.reset(target->createMCDisassembler(*m_subtype_info, *m_context));
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/MC/MCContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ class MCContext {

public:
LLVM_ABI explicit MCContext(const Triple &TheTriple, const MCAsmInfo &MAI,
const MCRegisterInfo *MRI,
const MCSubtargetInfo *MSTI,
const MCRegisterInfo &MRI,
const MCSubtargetInfo &MSTI,
const SourceMgr *Mgr = nullptr,
bool DoAutoReset = true,
StringRef Swift5ReflSegmentName = {});
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/Target/TargetMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,9 @@ class LLVM_ABI TargetMachine {
/// Return target specific asm information.
const MCAsmInfo &getMCAsmInfo() const { return *AsmInfo; }

const MCRegisterInfo *getMCRegisterInfo() const { return MRI.get(); }
const MCRegisterInfo &getMCRegisterInfo() const { return *MRI; }
const MCInstrInfo *getMCInstrInfo() const { return MII.get(); }
const MCSubtargetInfo *getMCSubtargetInfo() const { return STI.get(); }
const MCSubtargetInfo &getMCSubtargetInfo() const { return *STI; }

/// Return the ExceptionHandling to use, considering TargetOptions and the
/// Triple's default.
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ bool AsmPrinter::doInitialization(Module &M) {
// information (such as the embedded command line) to be associated
// with all sections in the object file rather than a single section.
if (!Target.isOSBinFormatXCOFF())
OutStreamer->initSections(*TM.getMCSubtargetInfo());
OutStreamer->initSections(TM.getMCSubtargetInfo());

// Emit the version-min deployment target directive if needed.
//
Expand Down Expand Up @@ -627,7 +627,7 @@ bool AsmPrinter::doInitialization(Module &M) {
OutStreamer->AddComment("Start of file scope inline assembly");
OutStreamer->addBlankLine();
emitInlineAsm(
M.getModuleInlineAsm() + "\n", *TM.getMCSubtargetInfo(),
M.getModuleInlineAsm() + "\n", TM.getMCSubtargetInfo(),
TM.Options.MCOptions, nullptr,
InlineAsm::AsmDialect(TM.getMCAsmInfo().getAssemblerDialect()));
OutStreamer->AddComment("End of file scope inline assembly");
Expand Down Expand Up @@ -2089,7 +2089,7 @@ void AsmPrinter::emitFunctionBody() {
if (this->MF)
STI = &getSubtargetInfo();
else
STI = TM.getMCSubtargetInfo();
STI = &TM.getMCSubtargetInfo();

bool CanDoExtraAnalysis = ORE->allowExtraAnalysis(DEBUG_TYPE);
// Create a slot for the entry basic block section so that the section
Expand Down Expand Up @@ -3845,7 +3845,7 @@ Align AsmPrinter::emitAlignment(Align Alignment, const GlobalObject *GV,
if (this->MF)
STI = &getSubtargetInfo();
else
STI = TM.getMCSubtargetInfo();
STI = &TM.getMCSubtargetInfo();
OutStreamer->emitCodeAlignment(Alignment, STI, MaxBytesToEmit);
} else
OutStreamer->emitValueToAlignment(Alignment, 0, 1, MaxBytesToEmit);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ void DwarfCompileUnit::addLocationAttribute(
// Base register
Register BaseReg = Asm->getObjFileLowering().getStaticBase();
unsigned DwarfBaseReg =
Asm->TM.getMCRegisterInfo()->getDwarfRegNum(BaseReg, false);
Asm->TM.getMCRegisterInfo().getDwarfRegNum(BaseReg, false);
addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_breg0 + DwarfBaseReg);
// Offset from base register
addSInt(*Loc, dwarf::DW_FORM_sdata, 0);
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/CodeGen/CodeGenTargetMachineImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ CodeGenTargetMachineImpl::createMCStreamer(raw_pwrite_stream &Out,
raw_pwrite_stream *DwoOut,
CodeGenFileType FileType,
MCContext &Context) {
const MCSubtargetInfo &STI = *getMCSubtargetInfo();
const MCSubtargetInfo &STI = getMCSubtargetInfo();
const MCAsmInfo &MAI = getMCAsmInfo();
const MCRegisterInfo &MRI = *getMCRegisterInfo();
const MCRegisterInfo &MRI = getMCRegisterInfo();
const MCInstrInfo &MII = *getMCInstrInfo();

std::unique_ptr<MCStreamer> AsmStreamer;
Expand Down Expand Up @@ -279,8 +279,8 @@ bool CodeGenTargetMachineImpl::addPassesToEmitMC(PassManagerBase &PM,

// Create the code emitter for the target if it exists. If not, .o file
// emission fails.
const MCSubtargetInfo &STI = *getMCSubtargetInfo();
const MCRegisterInfo &MRI = *getMCRegisterInfo();
const MCSubtargetInfo &STI = getMCSubtargetInfo();
const MCRegisterInfo &MRI = getMCRegisterInfo();
std::unique_ptr<MCCodeEmitter> MCE(
getTarget().createMCCodeEmitter(*getMCInstrInfo(), *Ctx));
if (!MCE)
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/DWARFLinker/Classic/DWARFStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Error DwarfStreamer::init(Triple TheTriple,
"no subtarget info for target %s",
TripleName.c_str());

MC.reset(new MCContext(TheTriple, *MAI, MRI.get(), MSTI.get(), nullptr, true,
MC.reset(new MCContext(TheTriple, *MAI, *MRI, *MSTI, nullptr, true,
Swift5ReflectionSegmentName));
MOFI.reset(TheTarget->createMCObjectFileInfo(*MC, /*PIC=*/false, false));
MC->setObjectFileInfo(MOFI.get());
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/DWARFLinker/Parallel/DWARFEmitterImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Error DwarfEmitterImpl::init(Triple TheTriple,
"no subtarget info for target %s",
TripleName.c_str());

MC.reset(new MCContext(TheTriple, *MAI, MRI.get(), MSTI.get(), nullptr, true,
MC.reset(new MCContext(TheTriple, *MAI, *MRI, *MSTI, nullptr, true,
Swift5ReflectionSegmentName));
MOFI.reset(TheTarget->createMCObjectFileInfo(*MC, /*PIC=*/false, false));
MC->setObjectFileInfo(MOFI.get());
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/DWARFLinker/Parallel/DebugLineSectionEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ class DebugLineSectionEmitter {
"no subtarget info for target %s",
TripleName.c_str());

MC.reset(new MCContext(TheTriple, *MAI, MRI.get(), MSTI.get(), nullptr,
true, "__DWARF"));
MC.reset(
new MCContext(TheTriple, *MAI, *MRI, *MSTI, nullptr, true, "__DWARF"));

return Error::success();
}
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,7 @@ Error LVBinaryReader::loadGenericTargetInfo(StringRef TripleName,
"no instruction info for target " + TripleName);
MII.reset(InstructionInfo);

MC = std::make_unique<MCContext>(Triple(TheTriple), *MAI, MRI.get(),
STI.get());
MC = std::make_unique<MCContext>(Triple(TheTriple), *MAI, *MRI, *STI);

// Assembler.
MCDisassembler *DisAsm(TheTarget->createMCDisassembler(*STI, *MC));
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,8 +785,7 @@ class RuntimeDyldCheckerExprEval {
TT.str(),
inconvertibleErrorCode());

auto Ctx = std::make_unique<MCContext>(Triple(TT.str()), *MAI, MRI.get(),
STI.get());
auto Ctx = std::make_unique<MCContext>(Triple(TT.str()), *MAI, *MRI, *STI);

std::unique_ptr<MCDisassembler> Disassembler(
TheTarget->createMCDisassembler(*STI, *Ctx));
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/MC/MCContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ static void defaultDiagHandler(const SMDiagnostic &SMD, bool, const SourceMgr &,
}

MCContext::MCContext(const Triple &TheTriple, const MCAsmInfo &mai,
const MCRegisterInfo *mri, const MCSubtargetInfo *msti,
const MCRegisterInfo &mri, const MCSubtargetInfo &msti,
const SourceMgr *mgr, bool DoAutoReset,
StringRef Swift5ReflSegmentName)
: Swift5ReflectionSegmentName(Swift5ReflSegmentName), TT(TheTriple),
SrcMgr(mgr), InlineSrcMgr(nullptr), DiagHandler(defaultDiagHandler),
MAI(mai), MRI(mri), MSTI(msti), Symbols(Allocator),
MAI(mai), MRI(&mri), MSTI(&msti), Symbols(Allocator),
InlineAsmUsedLabelNames(Allocator),
CurrentDwarfLoc(0, 0, 0, DWARF2_FLAG_IS_STMT, 0, 0),
AutoReset(DoAutoReset) {
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/MC/MCDisassembler/Disassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ LLVMCreateDisasmCPUFeatures(const char *TT, const char *CPU,
return nullptr;

// Set up the MCContext for creating symbols and MCExpr's.
std::unique_ptr<MCContext> Ctx(
new MCContext(TheTriple, *MAI, MRI.get(), STI.get()));
std::unique_ptr<MCContext> Ctx(new MCContext(TheTriple, *MAI, *MRI, *STI));
if (!Ctx)
return nullptr;

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Object/ModuleSymbolTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ initializeRecordStreamer(const Module &M,
SourceMgr SrcMgr;
SrcMgr.AddNewSourceBuffer(std::move(Buffer), SMLoc());

MCContext MCCtx(TT, *MAI, MRI.get(), STI.get(), &SrcMgr);
MCContext MCCtx(TT, *MAI, *MRI, *STI, &SrcMgr);
std::unique_ptr<MCObjectFileInfo> MOFI(
T->createMCObjectFileInfo(MCCtx, /*PIC=*/false));
MCCtx.setObjectFileInfo(MOFI.get());
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/AArch64TargetObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void AArch64_ELFTargetObjectFile::Initialize(MCContext &Ctx,
// Make sure the implicitly created empty .text section has the
// SHF_AARCH64_PURECODE flag set if the "+execute-only" target feature is
// present.
if (TM.getMCSubtargetInfo()->hasFeature(AArch64::FeatureExecuteOnly)) {
if (TM.getMCSubtargetInfo().hasFeature(AArch64::FeatureExecuteOnly)) {
auto *Text = static_cast<MCSectionELF *>(TextSection);
Text->setFlags(Text->getFlags() | ELF::SHF_AARCH64_PURECODE);
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ StringRef AMDGPUAsmPrinter::getPassName() const {
}

const MCSubtargetInfo *AMDGPUAsmPrinter::getGlobalSTI() const {
return TM.getMCSubtargetInfo();
return &TM.getMCSubtargetInfo();
}

AMDGPUTargetStreamer *AMDGPUAsmPrinter::getTargetStreamer() const {
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ bool AMDGPUResourceUsageAnalysisWrapperPass::runOnMachineFunction(
return false;

const TargetMachine &TM = TPC->getTM<TargetMachine>();
const MCSubtargetInfo &STI = *TM.getMCSubtargetInfo();
const MCSubtargetInfo &STI = TM.getMCSubtargetInfo();

// By default, for code object v5 and later, track only the minimum scratch
// size
Expand All @@ -104,7 +104,7 @@ AnalysisKey AMDGPUResourceUsageAnalysis::Key;
AMDGPUResourceUsageAnalysis::Result
AMDGPUResourceUsageAnalysis::run(MachineFunction &MF,
MachineFunctionAnalysisManager &MFAM) {
const MCSubtargetInfo &STI = *TM.getMCSubtargetInfo();
const MCSubtargetInfo &STI = TM.getMCSubtargetInfo();

// By default, for code object v5 and later, track only the minimum scratch
// size
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -878,9 +878,9 @@ AMDGPUTargetMachine::AMDGPUTargetMachine(const Target &T, const Triple &TT,
TLOF(createTLOF(getTargetTriple())) {
initAsmInfo();
if (TT.isAMDGCN()) {
if (getMCSubtargetInfo()->checkFeatures("+wavefrontsize64"))
if (getMCSubtargetInfo().checkFeatures("+wavefrontsize64"))
MRI.reset(llvm::createGCNMCRegisterInfo(AMDGPUDwarfFlavour::Wave64));
else if (getMCSubtargetInfo()->checkFeatures("+wavefrontsize32"))
else if (getMCSubtargetInfo().checkFeatures("+wavefrontsize32"))
MRI.reset(llvm::createGCNMCRegisterInfo(AMDGPUDwarfFlavour::Wave32));
}
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/ARM/ARMTargetObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void ARMElfTargetObjectFile::Initialize(MCContext &Ctx,
const ARMBaseTargetMachine &ARM_TM = static_cast<const ARMBaseTargetMachine &>(TM);
bool isAAPCS_ABI = ARM_TM.TargetABI == ARM::ARMABI::ARM_ABI_AAPCS;
bool genExecuteOnly =
ARM_TM.getMCSubtargetInfo()->hasFeature(ARM::FeatureExecuteOnly);
ARM_TM.getMCSubtargetInfo().hasFeature(ARM::FeatureExecuteOnly);

TargetLoweringObjectFileELF::Initialize(Ctx, TM);
InitializeELF(isAAPCS_ABI);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AVR/AVRAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace {
class AVRAsmPrinter : public AsmPrinter {
public:
AVRAsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer)
: AsmPrinter(TM, std::move(Streamer), ID), MRI(*TM.getMCRegisterInfo()) {}
: AsmPrinter(TM, std::move(Streamer), ID), MRI(TM.getMCRegisterInfo()) {}

StringRef getPassName() const override { return "AVR Assembly Printer"; }

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/CSKY/CSKYAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool CSKYAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
// Set the current MCSubtargetInfo to a copy which has the correct
// feature bits for the current MachineFunction
MCSubtargetInfo &NewSTI =
OutStreamer->getContext().getSubtargetCopy(*TM.getMCSubtargetInfo());
OutStreamer->getContext().getSubtargetCopy(TM.getMCSubtargetInfo());
NewSTI.setFeatureBits(MF.getSubtarget().getFeatureBits());
Subtarget = &NewSTI;

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/Hexagon/HexagonAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ void HexagonAsmPrinter::emitEndOfAsmFile(Module &M) {
void HexagonAsmPrinter::emitAttributes() {
HexagonTargetStreamer &HTS =
static_cast<HexagonTargetStreamer &>(*OutStreamer->getTargetStreamer());
HTS.emitTargetAttributes(*TM.getMCSubtargetInfo());
HTS.emitTargetAttributes(TM.getMCSubtargetInfo());
}

void HexagonAsmPrinter::EmitSled(const MachineInstr &MI, SledKind Kind) {
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Target/LoongArch/LoongArchAsmPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class LLVM_LIBRARY_VISIBILITY LoongArchAsmPrinter : public AsmPrinter {
public:
explicit LoongArchAsmPrinter(TargetMachine &TM,
std::unique_ptr<MCStreamer> Streamer)
: AsmPrinter(TM, std::move(Streamer), ID), STI(TM.getMCSubtargetInfo()) {}
: AsmPrinter(TM, std::move(Streamer), ID), STI(&TM.getMCSubtargetInfo()) {
}

StringRef getPassName() const override {
return "LoongArch Assembly Printer";
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ bool RISCVAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
bool RISCVAsmPrinter::emitDirectiveOptionArch() {
RISCVTargetStreamer &RTS = getTargetStreamer();
SmallVector<RISCVOptionArchArg> NeedEmitStdOptionArgs;
const MCSubtargetInfo &MCSTI = *TM.getMCSubtargetInfo();
const MCSubtargetInfo &MCSTI = TM.getMCSubtargetInfo();
for (const auto &Feature : RISCVFeatureKV) {
if (STI->hasFeature(Feature.Value) == MCSTI.hasFeature(Feature.Value))
continue;
Expand Down Expand Up @@ -556,7 +556,7 @@ void RISCVAsmPrinter::emitStartOfAsmFile(Module &M) {
dyn_cast_or_null<MDString>(M.getModuleFlag("target-abi")))
RTS.setTargetABI(RISCVABI::getTargetABI(ModuleTargetABI->getString()));

MCSubtargetInfo SubtargetInfo = *TM.getMCSubtargetInfo();
MCSubtargetInfo SubtargetInfo = TM.getMCSubtargetInfo();

// Use module flag to update feature bits.
if (auto *MD = dyn_cast_or_null<MDNode>(M.getModuleFlag("riscv-isa"))) {
Expand Down Expand Up @@ -730,7 +730,7 @@ void RISCVAsmPrinter::EmitHwasanMemaccessSymbols(Module &M) {
// Use MCSubtargetInfo from TargetMachine. Individual functions may have
// attributes that differ from other functions in the module and we have no
// way to know which function is correct.
const MCSubtargetInfo &MCSTI = *TM.getMCSubtargetInfo();
const MCSubtargetInfo &MCSTI = TM.getMCSubtargetInfo();

MCSymbol *HwasanTagMismatchV2Sym =
OutContext.getOrCreateSymbol("__hwasan_tag_mismatch_v2");
Expand Down
Loading