https://github.com/MaskRay created https://github.com/llvm/llvm-project/pull/180465
Preparatory change for storing the MCTargetOptions pointer in MCAsmInfo. >From 9fd411f6f48a7ab79c0e6f46ac73602e24f0cb4c Mon Sep 17 00:00:00 2001 From: Fangrui Song <[email protected]> Date: Sun, 8 Feb 2026 20:18:28 -0800 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.5-bogner --- 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()); _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
