https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/180464
>From 592552153923fb042a82166bdc6dbf858d0556f8 Mon Sep 17 00:00:00 2001 From: Fangrui Song <[email protected]> Date: Sun, 8 Feb 2026 20:18:07 -0800 Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?= =?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5-bogner [skip ci] --- bolt/include/bolt/Core/BinaryContext.h | 3 +++ bolt/lib/Core/BinaryContext.cpp | 3 ++- .../Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp | 7 +++++-- .../Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp | 3 +-- .../Plugins/Instruction/MIPS/EmulateInstructionMIPS.h | 3 +++ .../Instruction/MIPS64/EmulateInstructionMIPS64.cpp | 3 +-- .../Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h | 2 ++ .../llvm/DebugInfo/LogicalView/Readers/LVBinaryReader.h | 2 ++ llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp | 1 - llvm/tools/llvm-exegesis/lib/DisassemblerHelper.cpp | 3 +-- llvm/tools/llvm-exegesis/lib/DisassemblerHelper.h | 2 ++ .../DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp | 3 ++- llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp | 2 +- llvm/unittests/DebugInfo/DWARF/DwarfGenerator.h | 2 ++ llvm/unittests/MC/AMDGPU/Disassembler.cpp | 6 ++++-- llvm/unittests/MC/SystemZ/SystemZMCDisassemblerTest.cpp | 3 ++- llvm/unittests/MC/X86/X86MCDisassemblerTest.cpp | 3 ++- 17 files changed, 35 insertions(+), 16 deletions(-) diff --git a/bolt/include/bolt/Core/BinaryContext.h b/bolt/include/bolt/Core/BinaryContext.h index 31c90d2c502bd..0197046c9df0d 100644 --- a/bolt/include/bolt/Core/BinaryContext.h +++ b/bolt/include/bolt/Core/BinaryContext.h @@ -39,6 +39,7 @@ #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" +#include "llvm/MC/MCTargetOptions.h" #include "llvm/MC/TargetRegistry.h" #include "llvm/Support/ErrorOr.h" #include "llvm/Support/RWMutex.h" @@ -681,6 +682,8 @@ class BinaryContext { std::unique_ptr<MCObjectFileInfo> MOFI; + MCTargetOptions MCOptions; + std::unique_ptr<const MCAsmInfo> AsmInfo; std::unique_ptr<const MCInstrInfo> MII; diff --git a/bolt/lib/Core/BinaryContext.cpp b/bolt/lib/Core/BinaryContext.cpp index f0541921c70a8..005e2fc1e6bb5 100644 --- a/bolt/lib/Core/BinaryContext.cpp +++ b/bolt/lib/Core/BinaryContext.cpp @@ -225,8 +225,9 @@ Expected<std::unique_ptr<BinaryContext>> BinaryContext::createBinaryContext( Twine("BOLT-ERROR: no register info for target ", TripleName)); // Set up disassembler. + MCTargetOptions MCOptions; std::unique_ptr<MCAsmInfo> AsmInfo( - TheTarget->createMCAsmInfo(*MRI, TheTriple, MCTargetOptions())); + TheTarget->createMCAsmInfo(*MRI, TheTriple, MCOptions)); if (!AsmInfo) return createStringError( make_error_code(std::errc::not_supported), diff --git a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp index e8bb706f7aab6..8e495e20d254a 100644 --- a/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp +++ b/lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp @@ -77,6 +77,7 @@ class DisassemblerLLVMC::MCDisasmInstance { MCDisasmInstance(std::unique_ptr<llvm::MCInstrInfo> &&instr_info_up, std::unique_ptr<llvm::MCRegisterInfo> &®_info_up, std::unique_ptr<llvm::MCSubtargetInfo> &&subtarget_info_up, + llvm::MCTargetOptions mc_options, std::unique_ptr<llvm::MCAsmInfo> &&asm_info_up, std::unique_ptr<llvm::MCContext> &&context_up, std::unique_ptr<llvm::MCDisassembler> &&disasm_up, @@ -86,6 +87,7 @@ class DisassemblerLLVMC::MCDisasmInstance { std::unique_ptr<llvm::MCInstrInfo> m_instr_info_up; std::unique_ptr<llvm::MCRegisterInfo> m_reg_info_up; std::unique_ptr<llvm::MCSubtargetInfo> m_subtarget_info_up; + llvm::MCTargetOptions m_mc_options; std::unique_ptr<llvm::MCAsmInfo> m_asm_info_up; std::unique_ptr<llvm::MCContext> m_context_up; std::unique_ptr<llvm::MCDisassembler> m_disasm_up; @@ -1333,7 +1335,7 @@ DisassemblerLLVMC::MCDisasmInstance::Create(const char *triple_name, return Instance(new MCDisasmInstance( std::move(instr_info_up), std::move(reg_info_up), - std::move(subtarget_info_up), std::move(asm_info_up), + std::move(subtarget_info_up), MCOptions, std::move(asm_info_up), std::move(context_up), std::move(disasm_up), std::move(instr_printer_up), std::move(instr_analysis_up))); } @@ -1342,6 +1344,7 @@ DisassemblerLLVMC::MCDisasmInstance::MCDisasmInstance( std::unique_ptr<llvm::MCInstrInfo> &&instr_info_up, std::unique_ptr<llvm::MCRegisterInfo> &®_info_up, std::unique_ptr<llvm::MCSubtargetInfo> &&subtarget_info_up, + llvm::MCTargetOptions mc_options, std::unique_ptr<llvm::MCAsmInfo> &&asm_info_up, std::unique_ptr<llvm::MCContext> &&context_up, std::unique_ptr<llvm::MCDisassembler> &&disasm_up, @@ -1350,7 +1353,7 @@ DisassemblerLLVMC::MCDisasmInstance::MCDisasmInstance( : m_instr_info_up(std::move(instr_info_up)), m_reg_info_up(std::move(reg_info_up)), m_subtarget_info_up(std::move(subtarget_info_up)), - m_asm_info_up(std::move(asm_info_up)), + m_mc_options(mc_options), m_asm_info_up(std::move(asm_info_up)), m_context_up(std::move(context_up)), m_disasm_up(std::move(disasm_up)), m_instr_printer_up(std::move(instr_printer_up)), m_instr_analysis_up(std::move(instr_analysis_up)) { diff --git a/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp b/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp index 8bcb4e5535d28..b835fe0e896ad 100644 --- a/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp +++ b/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp @@ -153,8 +153,7 @@ EmulateInstructionMIPS::EmulateInstructionMIPS( m_insn_info.reset(target->createMCInstrInfo()); assert(m_insn_info.get()); - llvm::MCTargetOptions MCOptions; - m_asm_info.reset(target->createMCAsmInfo(*m_reg_info, triple, MCOptions)); + m_asm_info.reset(target->createMCAsmInfo(*m_reg_info, triple, m_mc_options)); m_subtype_info.reset(target->createMCSubtargetInfo(triple, cpu, features)); assert(m_asm_info.get() && m_subtype_info.get()); diff --git a/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h b/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h index 01692c65ae30b..8bab5370742c6 100644 --- a/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h +++ b/lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h @@ -10,6 +10,8 @@ #ifndef LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS_EMULATEINSTRUCTIONMIPS_H #define LLDB_SOURCE_PLUGINS_INSTRUCTION_MIPS_EMULATEINSTRUCTIONMIPS_H +#include "llvm/MC/MCTargetOptions.h" + namespace llvm { class MCDisassembler; class MCSubtargetInfo; @@ -210,6 +212,7 @@ class EmulateInstructionMIPS : public lldb_private::EmulateInstruction { std::unique_ptr<llvm::MCSubtargetInfo> m_subtype_info; std::unique_ptr<llvm::MCSubtargetInfo> m_alt_subtype_info; std::unique_ptr<llvm::MCRegisterInfo> m_reg_info; + llvm::MCTargetOptions m_mc_options; std::unique_ptr<llvm::MCAsmInfo> m_asm_info; std::unique_ptr<llvm::MCContext> m_context; std::unique_ptr<llvm::MCInstrInfo> m_insn_info; diff --git a/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp b/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp index ad55d0ba97ad1..e842bb99045e3 100644 --- a/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp +++ b/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.cpp @@ -157,8 +157,7 @@ EmulateInstructionMIPS64::EmulateInstructionMIPS64( m_insn_info.reset(target->createMCInstrInfo()); assert(m_insn_info.get()); - llvm::MCTargetOptions MCOptions; - m_asm_info.reset(target->createMCAsmInfo(*m_reg_info, triple, MCOptions)); + m_asm_info.reset(target->createMCAsmInfo(*m_reg_info, triple, m_mc_options)); m_subtype_info.reset(target->createMCSubtargetInfo(triple, cpu, features)); assert(m_asm_info.get() && m_subtype_info.get()); diff --git a/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h b/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h index 6becdf5e3c44e..0042537e2e0e7 100644 --- a/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h +++ b/lldb/source/Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h @@ -12,6 +12,7 @@ #include "lldb/Core/EmulateInstruction.h" #include "lldb/Interpreter/OptionValue.h" #include "lldb/Utility/Status.h" +#include "llvm/MC/MCTargetOptions.h" #include <optional> namespace llvm { @@ -173,6 +174,7 @@ class EmulateInstructionMIPS64 : public lldb_private::EmulateInstruction { std::unique_ptr<llvm::MCDisassembler> m_disasm; std::unique_ptr<llvm::MCSubtargetInfo> m_subtype_info; std::unique_ptr<llvm::MCRegisterInfo> m_reg_info; + llvm::MCTargetOptions m_mc_options; std::unique_ptr<llvm::MCAsmInfo> m_asm_info; std::unique_ptr<llvm::MCContext> m_context; std::unique_ptr<llvm::MCInstrInfo> m_insn_info; diff --git a/llvm/include/llvm/DebugInfo/LogicalView/Readers/LVBinaryReader.h b/llvm/include/llvm/DebugInfo/LogicalView/Readers/LVBinaryReader.h index cc8dda2f82bee..64389902ea6fd 100644 --- a/llvm/include/llvm/DebugInfo/LogicalView/Readers/LVBinaryReader.h +++ b/llvm/include/llvm/DebugInfo/LogicalView/Readers/LVBinaryReader.h @@ -23,6 +23,7 @@ #include "llvm/MC/MCObjectFileInfo.h" #include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCSubtargetInfo.h" +#include "llvm/MC/MCTargetOptions.h" #include "llvm/MC/TargetRegistry.h" #include "llvm/Object/COFF.h" #include "llvm/Object/ObjectFile.h" @@ -109,6 +110,7 @@ class LVBinaryReader : public LVReader { LVLines CULines; std::unique_ptr<const MCRegisterInfo> MRI; + MCTargetOptions MCOptions; std::unique_ptr<const MCAsmInfo> MAI; std::unique_ptr<const MCSubtargetInfo> STI; std::unique_ptr<const MCInstrInfo> MII; diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp index 0d0383158dd48..974fbd0997c01 100644 --- a/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp +++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp @@ -292,7 +292,6 @@ Error LVBinaryReader::loadGenericTargetInfo(StringRef TripleName, MRI.reset(RegisterInfo); // Assembler properties and features. - MCTargetOptions MCOptions; MCAsmInfo *AsmInfo(TheTarget->createMCAsmInfo(*MRI, TheTriple, MCOptions)); if (!AsmInfo) return createStringError(errc::invalid_argument, diff --git a/llvm/tools/llvm-exegesis/lib/DisassemblerHelper.cpp b/llvm/tools/llvm-exegesis/lib/DisassemblerHelper.cpp index ff19ddce4ac9c..caa66b1be2520 100644 --- a/llvm/tools/llvm-exegesis/lib/DisassemblerHelper.cpp +++ b/llvm/tools/llvm-exegesis/lib/DisassemblerHelper.cpp @@ -14,11 +14,10 @@ namespace llvm { namespace exegesis { DisassemblerHelper::DisassemblerHelper(const LLVMState &State) : State_(State) { - MCTargetOptions MCOptions; const auto &TM = State.getTargetMachine(); const auto &Triple = TM.getTargetTriple(); AsmInfo_.reset( - TM.getTarget().createMCAsmInfo(State_.getRegInfo(), Triple, MCOptions)); + TM.getTarget().createMCAsmInfo(State_.getRegInfo(), Triple, MCOptions_)); InstPrinter_.reset(TM.getTarget().createMCInstPrinter( Triple, 0 /*default variant*/, *AsmInfo_, State_.getInstrInfo(), State_.getRegInfo())); diff --git a/llvm/tools/llvm-exegesis/lib/DisassemblerHelper.h b/llvm/tools/llvm-exegesis/lib/DisassemblerHelper.h index b946e976fdd53..7540805c84aeb 100644 --- a/llvm/tools/llvm-exegesis/lib/DisassemblerHelper.h +++ b/llvm/tools/llvm-exegesis/lib/DisassemblerHelper.h @@ -20,6 +20,7 @@ #include "llvm/MC/MCContext.h" #include "llvm/MC/MCDisassembler/MCDisassembler.h" #include "llvm/MC/MCInstPrinter.h" +#include "llvm/MC/MCTargetOptions.h" #include <memory> @@ -42,6 +43,7 @@ class DisassemblerHelper { private: const LLVMState &State_; + MCTargetOptions MCOptions_; std::unique_ptr<MCContext> Context_; std::unique_ptr<MCAsmInfo> AsmInfo_; std::unique_ptr<MCInstPrinter> InstPrinter_; diff --git a/llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp b/llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp index f51c2004d46c0..037af87fdab09 100644 --- a/llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp @@ -49,6 +49,7 @@ class DWARFExpressionCopyBytesTest : public ::testing::Test { Triple TheTriple; std::unique_ptr<MCRegisterInfo> MRI; + MCTargetOptions MCOptions; std::unique_ptr<MCAsmInfo> MAI; std::unique_ptr<const MCSubtargetInfo> STI; const Target *TheTarget; @@ -64,7 +65,7 @@ class DWARFExpressionCopyBytesTest : public ::testing::Test { return; MRI.reset(TheTarget->createMCRegInfo(TheTriple)); - MAI.reset(TheTarget->createMCAsmInfo(*MRI, TheTriple, MCTargetOptions())); + MAI.reset(TheTarget->createMCAsmInfo(*MRI, TheTriple, MCOptions)); STI.reset(TheTarget->createMCSubtargetInfo(TheTriple, "", "")); } diff --git a/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp b/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp index 6f1935a4588ed..71f90a8d27a8f 100644 --- a/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp +++ b/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp @@ -460,7 +460,7 @@ llvm::Error dwarfgen::Generator::init(Triple TheTriple, uint16_t V) { TripleName, inconvertibleErrorCode()); - MCTargetOptions MCOptions = mc::InitMCTargetOptionsFromFlags(); + MCOptions = mc::InitMCTargetOptionsFromFlags(); MAI.reset(TheTarget->createMCAsmInfo(*MRI, TheTriple, MCOptions)); if (!MAI) return make_error<StringError>("no asm info for target " + TripleName, diff --git a/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.h b/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.h index 119d0c9cfd9ea..c617c67ee98b3 100644 --- a/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.h +++ b/llvm/unittests/DebugInfo/DWARF/DwarfGenerator.h @@ -17,6 +17,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/CodeGen/DIE.h" #include "llvm/DebugInfo/DWARF/DWARFDebugLine.h" +#include "llvm/MC/MCTargetOptions.h" #include "llvm/Support/Error.h" #include <memory> @@ -245,6 +246,7 @@ class LineTable { /// the returned compile unit and adding attributes and children to each DIE. class Generator { std::unique_ptr<MCRegisterInfo> MRI; + MCTargetOptions MCOptions; std::unique_ptr<MCAsmInfo> MAI; std::unique_ptr<MCContext> MC; MCAsmBackend *MAB; // Owned by MCStreamer diff --git a/llvm/unittests/MC/AMDGPU/Disassembler.cpp b/llvm/unittests/MC/AMDGPU/Disassembler.cpp index b5adf695d9e66..f824b0791153d 100644 --- a/llvm/unittests/MC/AMDGPU/Disassembler.cpp +++ b/llvm/unittests/MC/AMDGPU/Disassembler.cpp @@ -79,8 +79,9 @@ TEST(AMDGPUDisassembler, MultiDisassembler) { GTEST_SKIP(); std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TT)); + MCTargetOptions MCOptions; std::unique_ptr<MCAsmInfo> MAI( - TheTarget->createMCAsmInfo(*MRI, TT, MCTargetOptions())); + TheTarget->createMCAsmInfo(*MRI, TT, MCOptions)); std::unique_ptr<const MCInstrInfo> MII(TheTarget->createMCInstrInfo()); std::unique_ptr<MCSubtargetInfo> STI( TheTarget->createMCSubtargetInfo(TT, CPUName, "")); @@ -150,8 +151,9 @@ TEST(AMDGPUDisassembler, UCVersionOverride) { GTEST_SKIP(); std::unique_ptr<MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TT)); + MCTargetOptions MCOptions; std::unique_ptr<MCAsmInfo> MAI( - TheTarget->createMCAsmInfo(*MRI, TT, MCTargetOptions())); + TheTarget->createMCAsmInfo(*MRI, TT, MCOptions)); std::unique_ptr<const MCInstrInfo> MII(TheTarget->createMCInstrInfo()); std::unique_ptr<MCSubtargetInfo> STI( TheTarget->createMCSubtargetInfo(TT, CPUName, "")); diff --git a/llvm/unittests/MC/SystemZ/SystemZMCDisassemblerTest.cpp b/llvm/unittests/MC/SystemZ/SystemZMCDisassemblerTest.cpp index 25c22d1b4ba73..406dfdb589345 100644 --- a/llvm/unittests/MC/SystemZ/SystemZMCDisassemblerTest.cpp +++ b/llvm/unittests/MC/SystemZ/SystemZMCDisassemblerTest.cpp @@ -26,6 +26,7 @@ struct Context { static constexpr char TripleName[] = "systemz-unknown"; Triple TT; std::unique_ptr<MCRegisterInfo> MRI; + MCTargetOptions MCOptions; std::unique_ptr<MCAsmInfo> MAI; std::unique_ptr<MCContext> Ctx; std::unique_ptr<MCSubtargetInfo> STI; @@ -43,7 +44,7 @@ struct Context { return; MRI.reset(TheTarget->createMCRegInfo(TT)); - MAI.reset(TheTarget->createMCAsmInfo(*MRI, TT, MCTargetOptions())); + MAI.reset(TheTarget->createMCAsmInfo(*MRI, TT, MCOptions)); STI.reset(TheTarget->createMCSubtargetInfo(TT, "", "")); Ctx = std::make_unique<MCContext>(TT, MAI.get(), MRI.get(), STI.get()); diff --git a/llvm/unittests/MC/X86/X86MCDisassemblerTest.cpp b/llvm/unittests/MC/X86/X86MCDisassemblerTest.cpp index 6d44151b378b2..0f236bcb5308a 100644 --- a/llvm/unittests/MC/X86/X86MCDisassemblerTest.cpp +++ b/llvm/unittests/MC/X86/X86MCDisassemblerTest.cpp @@ -26,6 +26,7 @@ struct Context { static constexpr char TripleName[] = "x86_64-unknown-elf"; const Triple TheTriple; std::unique_ptr<MCRegisterInfo> MRI; + MCTargetOptions MCOptions; std::unique_ptr<MCAsmInfo> MAI; std::unique_ptr<MCContext> Ctx; std::unique_ptr<MCSubtargetInfo> STI; @@ -43,7 +44,7 @@ struct Context { return; MRI.reset(TheTarget->createMCRegInfo(TheTriple)); - MAI.reset(TheTarget->createMCAsmInfo(*MRI, TheTriple, MCTargetOptions())); + MAI.reset(TheTarget->createMCAsmInfo(*MRI, TheTriple, MCOptions)); STI.reset(TheTarget->createMCSubtargetInfo(TheTriple, "", "")); Ctx = std::make_unique<MCContext>(TheTriple, MAI.get(), MRI.get(), STI.get()); >From 3d2353bfd10a43748b9d99aa1cfecec01dc89120 Mon Sep 17 00:00:00 2001 From: Fangrui Song <[email protected]> Date: Sun, 8 Feb 2026 21:23:29 -0800 Subject: [PATCH 2/3] fix unittest Created using spr 1.3.5-bogner --- llvm/unittests/CodeGen/MFCommon.inc | 8 +++++++- llvm/unittests/CodeGen/MachineInstrTest.cpp | 3 +++ llvm/unittests/CodeGen/MachineOperandTest.cpp | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/llvm/unittests/CodeGen/MFCommon.inc b/llvm/unittests/CodeGen/MFCommon.inc index c5e1c747bce32..2e91675a08d69 100644 --- a/llvm/unittests/CodeGen/MFCommon.inc +++ b/llvm/unittests/CodeGen/MFCommon.inc @@ -118,7 +118,13 @@ public: : CodeGenTargetMachineImpl( Target(), "", Triple(""), "", "", getTargetOptionsForBogusMachine(), Reloc::Static, CodeModel::Small, CodeGenOptLevel::Default), - ST(*this) {} + ST(*this) { + // The empty Target() has no MCAsmInfoCtorFn, so createMCAsmInfo returns + // null. Provide a default MCAsmInfo so that MCContext can be created. + auto MAI = std::make_unique<MCAsmInfo>(); + MAI->setTargetOptions(Options.MCOptions); + AsmInfo = std::move(MAI); + } ~BogusTargetMachine() override = default; diff --git a/llvm/unittests/CodeGen/MachineInstrTest.cpp b/llvm/unittests/CodeGen/MachineInstrTest.cpp index ab28963b39311..f587dabd695bd 100644 --- a/llvm/unittests/CodeGen/MachineInstrTest.cpp +++ b/llvm/unittests/CodeGen/MachineInstrTest.cpp @@ -37,7 +37,10 @@ namespace { // Include helper functions to ease the manipulation of MachineFunctions. #include "MFCommon.inc" +MCTargetOptions MCOptions; + std::unique_ptr<MCContext> createMCContext(MCAsmInfo *AsmInfo) { + AsmInfo->setTargetOptions(MCOptions); Triple TheTriple(/*ArchStr=*/"", /*VendorStr=*/"", /*OSStr=*/"", /*EnvironmentStr=*/"elf"); return std::make_unique<MCContext>(TheTriple, AsmInfo, nullptr, nullptr, diff --git a/llvm/unittests/CodeGen/MachineOperandTest.cpp b/llvm/unittests/CodeGen/MachineOperandTest.cpp index c0b2b1895975a..23b896cfd8265 100644 --- a/llvm/unittests/CodeGen/MachineOperandTest.cpp +++ b/llvm/unittests/CodeGen/MachineOperandTest.cpp @@ -349,7 +349,9 @@ TEST(MachineOperandTest, PrintMetadata) { } TEST(MachineOperandTest, PrintMCSymbol) { + MCTargetOptions MCOptions; MCAsmInfo MAI; + MAI.setTargetOptions(MCOptions); Triple T = Triple("unknown-unknown-unknown"); MCContext Ctx(T, &MAI, /*MRI=*/nullptr, /*MSTI=*/nullptr); MCSymbol *Sym = Ctx.getOrCreateSymbol("foo"); >From 3b76dabb31797902c3e65d6e0ced0f9d108a1020 Mon Sep 17 00:00:00 2001 From: Fangrui Song <[email protected]> Date: Sun, 8 Feb 2026 23:19:34 -0800 Subject: [PATCH 3/3] BogusTargetmachine comment Created using spr 1.3.5-bogner --- llvm/unittests/CodeGen/MFCommon.inc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/unittests/CodeGen/MFCommon.inc b/llvm/unittests/CodeGen/MFCommon.inc index 2e91675a08d69..27f4c5163a111 100644 --- a/llvm/unittests/CodeGen/MFCommon.inc +++ b/llvm/unittests/CodeGen/MFCommon.inc @@ -119,11 +119,11 @@ public: Target(), "", Triple(""), "", "", getTargetOptionsForBogusMachine(), Reloc::Static, CodeModel::Small, CodeGenOptLevel::Default), ST(*this) { - // The empty Target() has no MCAsmInfoCtorFn, so createMCAsmInfo returns - // null. Provide a default MCAsmInfo so that MCContext can be created. + // With an empty Triple, `initAsmInfo` cannot be called. Provide a + // default MCAsmInfo so that MCContext can be created. auto MAI = std::make_unique<MCAsmInfo>(); + AsmInfo = std::make_unique<MCAsmInfo>(); MAI->setTargetOptions(Options.MCOptions); - AsmInfo = std::move(MAI); } ~BogusTargetMachine() override = default; _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
