Index: llvm/include/llvm/CodeGen/MachineFunction.h =================================================================== --- llvm/include/llvm/CodeGen/MachineFunction.h +++ llvm/include/llvm/CodeGen/MachineFunction.h @@ -99,9 +99,10 @@ /// supplied allocator. /// /// This function can be overridden in a derive class. - template - static Ty *create(BumpPtrAllocator &Allocator, MachineFunction &MF) { - return new (Allocator.Allocate()) Ty(MF); + template + static Ty *create(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) { + return new (Allocator.Allocate()) Ty(F, STI); } template @@ -753,14 +754,12 @@ /// template Ty *getInfo() { - if (!MFInfo) - MFInfo = Ty::template create(Allocator, *this); return static_cast(MFInfo); } template const Ty *getInfo() const { - return const_cast(this)->getInfo(); + return static_cast(MFInfo); } template Ty *cloneInfo(const Ty &Old) { @@ -769,6 +768,9 @@ return static_cast(MFInfo); } + /// Initialize the target specific MachineFunctionInfo + void initTargetMachineFunctionInfo(const TargetSubtargetInfo &STI); + MachineFunctionInfo *cloneInfoFrom( const MachineFunction &OrigMF, const DenseMap &Src2DstMBB) { Index: llvm/include/llvm/Target/TargetMachine.h =================================================================== --- llvm/include/llvm/Target/TargetMachine.h +++ llvm/include/llvm/Target/TargetMachine.h @@ -17,6 +17,7 @@ #include "llvm/ADT/Triple.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/PassManager.h" +#include "llvm/Support/Allocator.h" #include "llvm/Support/CodeGen.h" #include "llvm/Support/Error.h" #include "llvm/Support/PGOOptions.h" @@ -63,6 +64,7 @@ } using legacy::PassManagerBase; +struct MachineFunctionInfo; namespace yaml { struct MachineFunctionInfo; } @@ -136,6 +138,13 @@ return nullptr; } + /// Create the target's instance of MachineFunctionInfo + virtual MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return nullptr; + } + /// Allocate and return a default initialized instance of the YAML /// representation for the MachineFunctionInfo. virtual yaml::MachineFunctionInfo *createDefaultFuncInfoYAML() const { Index: llvm/lib/CodeGen/MachineFunction.cpp =================================================================== --- llvm/lib/CodeGen/MachineFunction.cpp +++ llvm/lib/CodeGen/MachineFunction.cpp @@ -187,6 +187,7 @@ RegInfo = nullptr; MFInfo = nullptr; + // We can realign the stack if the target supports it and the user hasn't // explicitly asked us not to. bool CanRealignSP = STI->getFrameLowering()->isStackRealignable() && @@ -232,6 +233,12 @@ PSVManager = std::make_unique(getTarget()); } +void MachineFunction::initTargetMachineFunctionInfo( + const TargetSubtargetInfo &STI) { + assert(!MFInfo && "MachineFunctionInfo already set"); + MFInfo = Target.createMachineFunctionInfo(Allocator, F, &STI); +} + MachineFunction::~MachineFunction() { clear(); } Index: llvm/lib/CodeGen/MachineModuleInfo.cpp =================================================================== --- llvm/lib/CodeGen/MachineModuleInfo.cpp +++ llvm/lib/CodeGen/MachineModuleInfo.cpp @@ -118,6 +118,7 @@ // No pre-existing machine function, create a new one. const TargetSubtargetInfo &STI = *TM.getSubtargetImpl(F); MF = new MachineFunction(F, TM, STI, NextFnNum++, *this); + MF->initTargetMachineFunctionInfo(STI); // Update the set entry. I.first->second.reset(MF); } else { Index: llvm/lib/CodeGen/ResetMachineFunctionPass.cpp =================================================================== --- llvm/lib/CodeGen/ResetMachineFunctionPass.cpp +++ llvm/lib/CodeGen/ResetMachineFunctionPass.cpp @@ -66,6 +66,8 @@ LLVM_DEBUG(dbgs() << "Resetting: " << MF.getName() << '\n'); ++NumFunctionsReset; MF.reset(); + MF.initTargetMachineFunctionInfo(MF.getSubtarget()); + if (EmitFallbackDiag) { const Function &F = MF.getFunction(); DiagnosticInfoISelFallback DiagFallback(F); Index: llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h =================================================================== --- llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h +++ llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.h @@ -192,7 +192,8 @@ mutable std::optional NeedsAsyncDwarfUnwindInfo; public: - explicit AArch64FunctionInfo(MachineFunction &MF); + explicit AArch64FunctionInfo(const Function &F, + const TargetSubtargetInfo *STI); MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, Index: llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp =================================================================== --- llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp +++ llvm/lib/Target/AArch64/AArch64MachineFunctionInfo.cpp @@ -82,9 +82,9 @@ return Key.equals_insensitive("b_key"); } -AArch64FunctionInfo::AArch64FunctionInfo(MachineFunction &MF) { - const Function &F = MF.getFunction(); - const AArch64Subtarget &STI = MF.getSubtarget(); +AArch64FunctionInfo::AArch64FunctionInfo(const Function &F, + const TargetSubtargetInfo *STI_) { + const AArch64Subtarget &STI = *static_cast(STI_); // If we already know that the function doesn't have a redzone, set // HasRedZone here. Index: llvm/lib/Target/AArch64/AArch64TargetMachine.h =================================================================== --- llvm/lib/Target/AArch64/AArch64TargetMachine.h +++ llvm/lib/Target/AArch64/AArch64TargetMachine.h @@ -49,6 +49,10 @@ return TLOF.get(); } + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; + yaml::MachineFunctionInfo *createDefaultFuncInfoYAML() const override; yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const override; Index: llvm/lib/Target/AArch64/AArch64TargetMachine.cpp =================================================================== --- llvm/lib/Target/AArch64/AArch64TargetMachine.cpp +++ llvm/lib/Target/AArch64/AArch64TargetMachine.cpp @@ -841,6 +841,12 @@ addPass(createUnpackMachineBundles(nullptr)); } +MachineFunctionInfo *AArch64TargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return AArch64FunctionInfo::create(Allocator, F, STI); +} + yaml::MachineFunctionInfo * AArch64TargetMachine::createDefaultFuncInfoYAML() const { return new yaml::AArch64FunctionInfo(); Index: llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.h =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.h +++ llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.h @@ -19,6 +19,9 @@ namespace llvm { +class AMDGPUSubtarget; +class GCNSubtarget; + class AMDGPUMachineFunction : public MachineFunctionInfo { /// A map to keep track of local memory objects and their offsets within the /// local memory space. @@ -60,7 +63,7 @@ bool WaveLimiter = false; public: - AMDGPUMachineFunction(const MachineFunction &MF); + AMDGPUMachineFunction(const Function &F, const AMDGPUSubtarget &ST); uint64_t getExplicitKernArgSize() const { return ExplicitKernArgSize; Index: llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp +++ llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp @@ -16,17 +16,17 @@ using namespace llvm; -AMDGPUMachineFunction::AMDGPUMachineFunction(const MachineFunction &MF) - : IsEntryFunction(AMDGPU::isEntryFunctionCC( - MF.getFunction().getCallingConv())), +AMDGPUMachineFunction::AMDGPUMachineFunction(const Function &F, + const AMDGPUSubtarget &ST) + : MachineFunctionInfo(), + IsEntryFunction( + AMDGPU::isEntryFunctionCC(F.getCallingConv())), IsModuleEntryFunction( - AMDGPU::isModuleEntryFunctionCC(MF.getFunction().getCallingConv())), - NoSignedZerosFPMath(MF.getTarget().Options.NoSignedZerosFPMath) { - const AMDGPUSubtarget &ST = AMDGPUSubtarget::get(MF); + AMDGPU::isModuleEntryFunctionCC(F.getCallingConv())), + NoSignedZerosFPMath(false) { // FIXME: Should initialize KernArgSize based on ExplicitKernelArgOffset, // except reserved size is not correctly aligned. - const Function &F = MF.getFunction(); Attribute MemBoundAttr = F.getFnAttribute("amdgpu-memory-bound"); MemoryBound = MemBoundAttr.getValueAsBool(); @@ -46,6 +46,11 @@ CallingConv::ID CC = F.getCallingConv(); if (CC == CallingConv::AMDGPU_KERNEL || CC == CallingConv::SPIR_KERNEL) ExplicitKernArgSize = ST.getExplicitKernArgSize(F, MaxKernArgAlign); + + // FIXME: Shouldn't be target specific + Attribute NSZAttr = F.getFnAttribute("no-signed-zeros-fp-math"); + NoSignedZerosFPMath = NSZAttr.isStringAttribute() && + NSZAttr.getValueAsString() == "true"; } unsigned AMDGPUMachineFunction::allocateLDSGlobal(const DataLayout &DL, Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h +++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.h @@ -92,6 +92,10 @@ return true; } + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; + yaml::MachineFunctionInfo *createDefaultFuncInfoYAML() const override; yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const override; Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -26,6 +26,7 @@ #include "GCNVOPDUtils.h" #include "R600.h" #include "R600TargetMachine.h" +#include "R600MachineFunctionInfo.h" #include "SIMachineFunctionInfo.h" #include "SIMachineScheduler.h" #include "TargetInfo/AMDGPUTargetInfo.h" @@ -1087,6 +1088,13 @@ return DAG; } +MachineFunctionInfo *R600TargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return R600MachineFunctionInfo::create(Allocator, F, + STI); +} + //===----------------------------------------------------------------------===// // GCN Pass Setup //===----------------------------------------------------------------------===// @@ -1403,6 +1411,13 @@ return new GCNPassConfig(*this, PM); } +MachineFunctionInfo *GCNTargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return SIMachineFunctionInfo::create(Allocator, F, + STI); +} + yaml::MachineFunctionInfo *GCNTargetMachine::createDefaultFuncInfoYAML() const { return new yaml::SIMachineFunctionInfo(); } Index: llvm/lib/Target/AMDGPU/R600MachineFunctionInfo.h =================================================================== --- llvm/lib/Target/AMDGPU/R600MachineFunctionInfo.h +++ llvm/lib/Target/AMDGPU/R600MachineFunctionInfo.h @@ -18,7 +18,7 @@ class R600MachineFunctionInfo final : public AMDGPUMachineFunction { public: - R600MachineFunctionInfo(const MachineFunction &MF); + R600MachineFunctionInfo(const Function &F, const TargetSubtargetInfo *STI); unsigned CFStackSize; }; Index: llvm/lib/Target/AMDGPU/R600MachineFunctionInfo.cpp =================================================================== --- llvm/lib/Target/AMDGPU/R600MachineFunctionInfo.cpp +++ llvm/lib/Target/AMDGPU/R600MachineFunctionInfo.cpp @@ -8,8 +8,11 @@ //===----------------------------------------------------------------------===// #include "R600MachineFunctionInfo.h" +#include "R600Subtarget.h" using namespace llvm; -R600MachineFunctionInfo::R600MachineFunctionInfo(const MachineFunction &MF) - : AMDGPUMachineFunction(MF) { } +R600MachineFunctionInfo::R600MachineFunctionInfo(const Function &F, + const TargetSubtargetInfo *STI) + : AMDGPUMachineFunction(F, static_cast(*STI)) { +} Index: llvm/lib/Target/AMDGPU/R600TargetMachine.h =================================================================== --- llvm/lib/Target/AMDGPU/R600TargetMachine.h +++ llvm/lib/Target/AMDGPU/R600TargetMachine.h @@ -43,6 +43,10 @@ TargetTransformInfo getTargetTransformInfo(const Function &F) const override; bool isMachineVerifierClean() const override { return false; } + + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; }; } // end namespace llvm Index: llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h =================================================================== --- llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h +++ llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h @@ -511,8 +511,8 @@ bool isCalleeSavedReg(const MCPhysReg *CSRegs, MCPhysReg Reg); public: - SIMachineFunctionInfo(const MachineFunction &MF); SIMachineFunctionInfo(const SIMachineFunctionInfo &MFI) = default; + SIMachineFunctionInfo(const Function &F, const TargetSubtargetInfo *STI); MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, Index: llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp =================================================================== --- llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp +++ llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp @@ -29,10 +29,17 @@ using namespace llvm; -SIMachineFunctionInfo::SIMachineFunctionInfo(const MachineFunction &MF) - : AMDGPUMachineFunction(MF), - Mode(MF.getFunction()), - GWSResourcePSV(static_cast(MF.getTarget())), +const GCNTargetMachine &getTM(const TargetSubtargetInfo *STI) { + const SITargetLowering *TLI + = static_cast(STI)->getTargetLowering(); + return static_cast(TLI->getTargetMachine()); +} + +SIMachineFunctionInfo::SIMachineFunctionInfo(const Function &F, + const TargetSubtargetInfo *STI) + : AMDGPUMachineFunction(F, static_cast(*STI)), + Mode(F), + GWSResourcePSV(getTM(STI)), PrivateSegmentBuffer(false), DispatchPtr(false), QueuePtr(false), @@ -52,8 +59,7 @@ ImplicitArgPtr(false), GITPtrHigh(0xffffffff), HighBitsOf32BitAddress(0) { - const GCNSubtarget &ST = MF.getSubtarget(); - const Function &F = MF.getFunction(); + const GCNSubtarget &ST = *static_cast(STI); FlatWorkGroupSizes = ST.getFlatWorkGroupSizes(F); WavesPerEU = ST.getWavesPerEU(F); Index: llvm/lib/Target/ARC/ARCMachineFunctionInfo.h =================================================================== --- llvm/lib/Target/ARC/ARCMachineFunctionInfo.h +++ llvm/lib/Target/ARC/ARCMachineFunctionInfo.h @@ -27,11 +27,7 @@ unsigned ReturnStackOffset; public: - ARCFunctionInfo() - : ReturnStackOffsetSet(false), VarArgsFrameIndex(0), - ReturnStackOffset(-1U), MaxCallStackReq(0) {} - - explicit ARCFunctionInfo(MachineFunction &MF) + explicit ARCFunctionInfo(const Function &F, const TargetSubtargetInfo *STI) : ReturnStackOffsetSet(false), VarArgsFrameIndex(0), ReturnStackOffset(-1U), MaxCallStackReq(0) {} ~ARCFunctionInfo() {} Index: llvm/lib/Target/ARC/ARCTargetMachine.cpp =================================================================== --- llvm/lib/Target/ARC/ARCTargetMachine.cpp +++ llvm/lib/Target/ARC/ARCTargetMachine.cpp @@ -79,6 +79,12 @@ addPass(createARCOptAddrMode()); } +MachineFunctionInfo *ARCTargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return ARCFunctionInfo::create(Allocator, F, STI); +} + // Force static initialization. extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARCTarget() { RegisterTargetMachine X(getTheARCTarget()); Index: llvm/lib/Target/ARM/ARMMachineFunctionInfo.h =================================================================== --- llvm/lib/Target/ARM/ARMMachineFunctionInfo.h +++ llvm/lib/Target/ARM/ARMMachineFunctionInfo.h @@ -157,7 +157,7 @@ public: ARMFunctionInfo() = default; - explicit ARMFunctionInfo(MachineFunction &MF); + explicit ARMFunctionInfo(const Function &F, const TargetSubtargetInfo *STI); MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, Index: llvm/lib/Target/ARM/ARMMachineFunctionInfo.cpp =================================================================== --- llvm/lib/Target/ARM/ARMMachineFunctionInfo.cpp +++ llvm/lib/Target/ARM/ARMMachineFunctionInfo.cpp @@ -13,12 +13,12 @@ void ARMFunctionInfo::anchor() {} -static bool GetBranchTargetEnforcement(MachineFunction &MF) { - const auto &Subtarget = MF.getSubtarget(); +static bool GetBranchTargetEnforcement(const Function &F, + const TargetSubtargetInfo *STI) { + const auto &Subtarget = *static_cast(STI); if (!Subtarget.isMClass() || !Subtarget.hasV7Ops()) return false; - const Function &F = MF.getFunction(); if (!F.hasFnAttribute("branch-target-enforcement")) { if (const auto *BTE = mdconst::extract_or_null( F.getParent()->getModuleFlag("branch-target-enforcement"))) @@ -61,17 +61,16 @@ return {true, false}; } -ARMFunctionInfo::ARMFunctionInfo(MachineFunction &MF) - : isThumb(MF.getSubtarget().isThumb()), - hasThumb2(MF.getSubtarget().hasThumb2()), - IsCmseNSEntry(MF.getFunction().hasFnAttribute("cmse_nonsecure_entry")), - IsCmseNSCall(MF.getFunction().hasFnAttribute("cmse_nonsecure_call")), - BranchTargetEnforcement(GetBranchTargetEnforcement(MF)) { - - const auto &Subtarget = MF.getSubtarget(); +ARMFunctionInfo::ARMFunctionInfo(const Function &F, + const TargetSubtargetInfo *STI) + : isThumb(static_cast(STI)->isThumb()), + hasThumb2(static_cast(STI)->hasThumb2()), + IsCmseNSEntry(F.hasFnAttribute("cmse_nonsecure_entry")), + IsCmseNSCall(F.hasFnAttribute("cmse_nonsecure_call")), + BranchTargetEnforcement(GetBranchTargetEnforcement(F, STI)) { + const auto &Subtarget = *static_cast(STI); if (Subtarget.isMClass() && Subtarget.hasV7Ops()) - std::tie(SignReturnAddress, SignReturnAddressAll) = - GetSignReturnAddress(MF.getFunction()); + std::tie(SignReturnAddress, SignReturnAddressAll) = GetSignReturnAddress(F); } MachineFunctionInfo * @@ -80,3 +79,4 @@ &Src2DstMBB) const { return DestMF.cloneInfo(*this); } + Index: llvm/lib/Target/ARM/ARMTargetMachine.h =================================================================== --- llvm/lib/Target/ARM/ARMTargetMachine.h +++ llvm/lib/Target/ARM/ARMTargetMachine.h @@ -74,6 +74,10 @@ bool targetSchedulesPostRAScheduling() const override { return true; }; + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; + /// Returns true if a cast between SrcAS and DestAS is a noop. bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override { // Addrspacecasts are always noops. Index: llvm/lib/Target/ARM/ARMTargetMachine.cpp =================================================================== --- llvm/lib/Target/ARM/ARMTargetMachine.cpp +++ llvm/lib/Target/ARM/ARMTargetMachine.cpp @@ -11,6 +11,7 @@ #include "ARMTargetMachine.h" #include "ARM.h" +#include "ARMMachineFunctionInfo.h" #include "ARMMacroFusion.h" #include "ARMSubtarget.h" #include "ARMTargetObjectFile.h" @@ -264,6 +265,12 @@ ARMBaseTargetMachine::~ARMBaseTargetMachine() = default; +MachineFunctionInfo *ARMBaseTargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return ARMFunctionInfo::create(Allocator, F, STI); +} + const ARMSubtarget * ARMBaseTargetMachine::getSubtargetImpl(const Function &F) const { Attribute CPUAttr = F.getFnAttribute("target-cpu"); Index: llvm/lib/Target/AVR/AVRMachineFunctionInfo.h =================================================================== --- llvm/lib/Target/AVR/AVRMachineFunctionInfo.h +++ llvm/lib/Target/AVR/AVRMachineFunctionInfo.h @@ -45,20 +45,16 @@ int VarArgsFrameIndex; public: - AVRMachineFunctionInfo() - : HasSpills(false), HasAllocas(false), HasStackArgs(false), - IsInterruptHandler(false), IsSignalHandler(false), - CalleeSavedFrameSize(0), VarArgsFrameIndex(0) {} - - explicit AVRMachineFunctionInfo(MachineFunction &MF) + explicit AVRMachineFunctionInfo(const Function &F, + const TargetSubtargetInfo *STI) : HasSpills(false), HasAllocas(false), HasStackArgs(false), CalleeSavedFrameSize(0), VarArgsFrameIndex(0) { - unsigned CallConv = MF.getFunction().getCallingConv(); + CallingConv::ID CallConv = F.getCallingConv(); this->IsInterruptHandler = CallConv == CallingConv::AVR_INTR || - MF.getFunction().hasFnAttribute("interrupt"); + F.hasFnAttribute("interrupt"); this->IsSignalHandler = CallConv == CallingConv::AVR_SIGNAL || - MF.getFunction().hasFnAttribute("signal"); + F.hasFnAttribute("signal"); } MachineFunctionInfo * Index: llvm/lib/Target/AVR/AVRTargetMachine.h =================================================================== --- llvm/lib/Target/AVR/AVRTargetMachine.h +++ llvm/lib/Target/AVR/AVRTargetMachine.h @@ -44,6 +44,10 @@ TargetPassConfig *createPassConfig(PassManagerBase &PM) override; + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; + private: std::unique_ptr TLOF; AVRSubtarget SubTarget; Index: llvm/lib/Target/AVR/AVRTargetMachine.cpp =================================================================== --- llvm/lib/Target/AVR/AVRTargetMachine.cpp +++ llvm/lib/Target/AVR/AVRTargetMachine.cpp @@ -19,6 +19,7 @@ #include "llvm/MC/TargetRegistry.h" #include "AVR.h" +#include "AVRMachineFunctionInfo.h" #include "AVRTargetObjectFile.h" #include "MCTargetDesc/AVRMCTargetDesc.h" #include "TargetInfo/AVRTargetInfo.h" @@ -105,6 +106,13 @@ return &SubTarget; } +MachineFunctionInfo *AVRTargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return AVRMachineFunctionInfo::create(Allocator, F, + STI); +} + //===----------------------------------------------------------------------===// // Pass Pipeline Configuration //===----------------------------------------------------------------------===// Index: llvm/lib/Target/Hexagon/HexagonMachineFunctionInfo.h =================================================================== --- llvm/lib/Target/Hexagon/HexagonMachineFunctionInfo.h +++ llvm/lib/Target/Hexagon/HexagonMachineFunctionInfo.h @@ -40,7 +40,9 @@ public: HexagonMachineFunctionInfo() = default; - HexagonMachineFunctionInfo(MachineFunction &MF) {} + HexagonMachineFunctionInfo(const Function &F, + const TargetSubtargetInfo *STI) {} + MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, const DenseMap &Src2DstMBB) Index: llvm/lib/Target/Hexagon/HexagonTargetMachine.h =================================================================== --- llvm/lib/Target/Hexagon/HexagonTargetMachine.h +++ llvm/lib/Target/Hexagon/HexagonTargetMachine.h @@ -45,6 +45,10 @@ HexagonTargetObjectFile *getObjFileLowering() const override { return static_cast(TLOF.get()); } + + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; }; } // end namespace llvm Index: llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp =================================================================== --- llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp +++ llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp @@ -14,6 +14,7 @@ #include "Hexagon.h" #include "HexagonISelLowering.h" #include "HexagonLoopIdiomRecognition.h" +#include "HexagonMachineFunctionInfo.h" #include "HexagonMachineScheduler.h" #include "HexagonTargetObjectFile.h" #include "HexagonTargetTransformInfo.h" @@ -289,6 +290,13 @@ return TargetTransformInfo(HexagonTTIImpl(this, F)); } +MachineFunctionInfo *HexagonTargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return HexagonMachineFunctionInfo::create( + Allocator, F, STI); +} + HexagonTargetMachine::~HexagonTargetMachine() = default; namespace { Index: llvm/lib/Target/Lanai/LanaiMachineFunctionInfo.h =================================================================== --- llvm/lib/Target/Lanai/LanaiMachineFunctionInfo.h +++ llvm/lib/Target/Lanai/LanaiMachineFunctionInfo.h @@ -38,7 +38,8 @@ int VarArgsFrameIndex; public: - explicit LanaiMachineFunctionInfo(MachineFunction &MF) + explicit LanaiMachineFunctionInfo(const Function &F, + const TargetSubtargetInfo *STI) : VarArgsFrameIndex(0) {} MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, Index: llvm/lib/Target/Lanai/LanaiTargetMachine.h =================================================================== --- llvm/lib/Target/Lanai/LanaiTargetMachine.h +++ llvm/lib/Target/Lanai/LanaiTargetMachine.h @@ -48,6 +48,10 @@ return TLOF.get(); } + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; + bool isMachineVerifierClean() const override { return false; } Index: llvm/lib/Target/Lanai/LanaiTargetMachine.cpp =================================================================== --- llvm/lib/Target/Lanai/LanaiTargetMachine.cpp +++ llvm/lib/Target/Lanai/LanaiTargetMachine.cpp @@ -13,6 +13,7 @@ #include "LanaiTargetMachine.h" #include "Lanai.h" +#include "LanaiMachineFunctionInfo.h" #include "LanaiTargetObjectFile.h" #include "LanaiTargetTransformInfo.h" #include "TargetInfo/LanaiTargetInfo.h" @@ -72,6 +73,13 @@ return TargetTransformInfo(LanaiTTIImpl(this, F)); } +MachineFunctionInfo *LanaiTargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return LanaiMachineFunctionInfo::create(Allocator, + F, STI); +} + namespace { // Lanai Code Generator Pass Configuration Options. class LanaiPassConfig : public TargetPassConfig { Index: llvm/lib/Target/MSP430/MSP430MachineFunctionInfo.h =================================================================== --- llvm/lib/Target/MSP430/MSP430MachineFunctionInfo.h +++ llvm/lib/Target/MSP430/MSP430MachineFunctionInfo.h @@ -40,7 +40,8 @@ public: MSP430MachineFunctionInfo() = default; - explicit MSP430MachineFunctionInfo(MachineFunction &MF) + explicit MSP430MachineFunctionInfo(const Function &F, + const TargetSubtargetInfo *STI) : CalleeSavedFrameSize(0), ReturnAddrIndex(0), SRetReturnReg(0) {} MachineFunctionInfo * Index: llvm/lib/Target/MSP430/MSP430TargetMachine.h =================================================================== --- llvm/lib/Target/MSP430/MSP430TargetMachine.h +++ llvm/lib/Target/MSP430/MSP430TargetMachine.h @@ -43,6 +43,10 @@ TargetLoweringObjectFile *getObjFileLowering() const override { return TLOF.get(); } + + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; }; // MSP430TargetMachine. } // end namespace llvm Index: llvm/lib/Target/MSP430/MSP430TargetMachine.cpp =================================================================== --- llvm/lib/Target/MSP430/MSP430TargetMachine.cpp +++ llvm/lib/Target/MSP430/MSP430TargetMachine.cpp @@ -12,6 +12,7 @@ #include "MSP430TargetMachine.h" #include "MSP430.h" +#include "MSP430MachineFunctionInfo.h" #include "TargetInfo/MSP430TargetInfo.h" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" @@ -72,6 +73,13 @@ return new MSP430PassConfig(*this, PM); } +MachineFunctionInfo *MSP430TargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return MSP430MachineFunctionInfo::create(Allocator, + F, STI); +} + bool MSP430PassConfig::addInstSelector() { // Install an instruction selector. addPass(createMSP430ISelDag(getMSP430TargetMachine(), getOptLevel())); Index: llvm/lib/Target/Mips/MipsMachineFunction.h =================================================================== --- llvm/lib/Target/Mips/MipsMachineFunction.h +++ llvm/lib/Target/Mips/MipsMachineFunction.h @@ -24,7 +24,7 @@ /// Mips target-specific information for each MachineFunction. class MipsFunctionInfo : public MachineFunctionInfo { public: - MipsFunctionInfo(MachineFunction &MF) {} + MipsFunctionInfo(const Function &F, const TargetSubtargetInfo *STI) {} MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, Index: llvm/lib/Target/Mips/MipsTargetMachine.h =================================================================== --- llvm/lib/Target/Mips/MipsTargetMachine.h +++ llvm/lib/Target/Mips/MipsTargetMachine.h @@ -64,6 +64,10 @@ return TLOF.get(); } + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; + /// Returns true if a cast between SrcAS and DestAS is a noop. bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override { // Mips doesn't have any special address spaces so we just reserve Index: llvm/lib/Target/Mips/MipsTargetMachine.cpp =================================================================== --- llvm/lib/Target/Mips/MipsTargetMachine.cpp +++ llvm/lib/Target/Mips/MipsTargetMachine.cpp @@ -15,6 +15,7 @@ #include "MCTargetDesc/MipsMCTargetDesc.h" #include "Mips.h" #include "Mips16ISelDAGToDAG.h" +#include "MipsMachineFunction.h" #include "MipsSEISelDAGToDAG.h" #include "MipsSubtarget.h" #include "MipsTargetObjectFile.h" @@ -292,6 +293,12 @@ return TargetTransformInfo(MipsTTIImpl(this, F)); } +MachineFunctionInfo *MipsTargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return MipsFunctionInfo::create(Allocator, F, STI); +} + // Implemented by targets that want to run passes immediately before // machine code is emitted. void MipsPassConfig::addPreEmitPass() { Index: llvm/lib/Target/NVPTX/NVPTXMachineFunctionInfo.h =================================================================== --- llvm/lib/Target/NVPTX/NVPTXMachineFunctionInfo.h +++ llvm/lib/Target/NVPTX/NVPTXMachineFunctionInfo.h @@ -24,7 +24,7 @@ SmallVector ImageHandleList; public: - NVPTXMachineFunctionInfo(MachineFunction &MF) {} + NVPTXMachineFunctionInfo(const Function &F, const TargetSubtargetInfo *STI) {} MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, Index: llvm/lib/Target/NVPTX/NVPTXTargetMachine.h =================================================================== --- llvm/lib/Target/NVPTX/NVPTXTargetMachine.h +++ llvm/lib/Target/NVPTX/NVPTXTargetMachine.h @@ -63,6 +63,10 @@ return TLOF.get(); } + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; + void registerPassBuilderCallbacks(PassBuilder &PB) override; TargetTransformInfo getTargetTransformInfo(const Function &F) const override; Index: llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp =================================================================== --- llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp +++ llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp @@ -15,6 +15,7 @@ #include "NVPTXAllocaHoisting.h" #include "NVPTXAtomicLower.h" #include "NVPTXLowerAggrCopies.h" +#include "NVPTXMachineFunctionInfo.h" #include "NVPTXTargetObjectFile.h" #include "NVPTXTargetTransformInfo.h" #include "TargetInfo/NVPTXTargetInfo.h" @@ -201,6 +202,13 @@ return new NVPTXPassConfig(*this, PM); } +MachineFunctionInfo *NVPTXTargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return NVPTXMachineFunctionInfo::create(Allocator, + F, STI); +} + void NVPTXTargetMachine::registerPassBuilderCallbacks(PassBuilder &PB) { PB.registerPipelineParsingCallback( [](StringRef PassName, FunctionPassManager &PM, Index: llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h =================================================================== --- llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h +++ llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.h @@ -151,7 +151,7 @@ std::vector> LiveInAttrs; public: - explicit PPCFunctionInfo(const MachineFunction &MF); + explicit PPCFunctionInfo(const Function &F, const TargetSubtargetInfo *STI); MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, Index: llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp =================================================================== --- llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp +++ llvm/lib/Target/PowerPC/PPCMachineFunctionInfo.cpp @@ -20,7 +20,8 @@ cl::init(false), cl::Hidden); void PPCFunctionInfo::anchor() {} -PPCFunctionInfo::PPCFunctionInfo(const MachineFunction &MF) +PPCFunctionInfo::PPCFunctionInfo(const Function &F, + const TargetSubtargetInfo *STI) : DisableNonVolatileCR(PPCDisableNonVolatileCR) {} MachineFunctionInfo * Index: llvm/lib/Target/PowerPC/PPCTargetMachine.h =================================================================== --- llvm/lib/Target/PowerPC/PPCTargetMachine.h +++ llvm/lib/Target/PowerPC/PPCTargetMachine.h @@ -58,6 +58,11 @@ TargetLoweringObjectFile *getObjFileLowering() const override { return TLOF.get(); } + + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; + bool isELFv2ABI() const { return TargetABI == PPC_ABI_ELFv2; } bool isPPC64() const { const Triple &TT = getTargetTriple(); Index: llvm/lib/Target/PowerPC/PPCTargetMachine.cpp =================================================================== --- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp +++ llvm/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -13,6 +13,7 @@ #include "PPCTargetMachine.h" #include "MCTargetDesc/PPCMCTargetDesc.h" #include "PPC.h" +#include "PPCMachineFunctionInfo.h" #include "PPCMachineScheduler.h" #include "PPCMacroFusion.h" #include "PPCSubtarget.h" @@ -579,6 +580,12 @@ return Endianness == Endian::LITTLE; } +MachineFunctionInfo *PPCTargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return PPCFunctionInfo::create(Allocator, F, STI); +} + static MachineSchedRegistry PPCPreRASchedRegistry("ppc-prera", "Run PowerPC PreRA specific scheduler", Index: llvm/lib/Target/RISCV/RISCVMachineFunctionInfo.h =================================================================== --- llvm/lib/Target/RISCV/RISCVMachineFunctionInfo.h +++ llvm/lib/Target/RISCV/RISCVMachineFunctionInfo.h @@ -72,7 +72,7 @@ SmallVector SExt32Registers; public: - RISCVMachineFunctionInfo(const MachineFunction &MF) {} + RISCVMachineFunctionInfo(const Function &F, const TargetSubtargetInfo *STI) {} MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, Index: llvm/lib/Target/RISCV/RISCVTargetMachine.h =================================================================== --- llvm/lib/Target/RISCV/RISCVTargetMachine.h +++ llvm/lib/Target/RISCV/RISCVTargetMachine.h @@ -44,6 +44,10 @@ return TLOF.get(); } + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; + TargetTransformInfo getTargetTransformInfo(const Function &F) const override; bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DstAS) const override; Index: llvm/lib/Target/RISCV/RISCVTargetMachine.cpp =================================================================== --- llvm/lib/Target/RISCV/RISCVTargetMachine.cpp +++ llvm/lib/Target/RISCV/RISCVTargetMachine.cpp @@ -131,6 +131,13 @@ return I.get(); } +MachineFunctionInfo *RISCVTargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return RISCVMachineFunctionInfo::create(Allocator, + F, STI); +} + TargetTransformInfo RISCVTargetMachine::getTargetTransformInfo(const Function &F) const { return TargetTransformInfo(RISCVTTIImpl(this, F)); Index: llvm/lib/Target/Sparc/SparcMachineFunctionInfo.h =================================================================== --- llvm/lib/Target/Sparc/SparcMachineFunctionInfo.h +++ llvm/lib/Target/Sparc/SparcMachineFunctionInfo.h @@ -34,7 +34,8 @@ SparcMachineFunctionInfo() : GlobalBaseReg(0), VarArgsFrameOffset(0), SRetReturnReg(0), IsLeafProc(false) {} - explicit SparcMachineFunctionInfo(MachineFunction &MF) + explicit SparcMachineFunctionInfo(const Function &F, + const TargetSubtargetInfo *STI) : GlobalBaseReg(0), VarArgsFrameOffset(0), SRetReturnReg(0), IsLeafProc(false) {} Index: llvm/lib/Target/Sparc/SparcTargetMachine.h =================================================================== --- llvm/lib/Target/Sparc/SparcTargetMachine.h +++ llvm/lib/Target/Sparc/SparcTargetMachine.h @@ -42,6 +42,10 @@ TargetLoweringObjectFile *getObjFileLowering() const override { return TLOF.get(); } + + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; }; /// Sparc 32-bit target machine Index: llvm/lib/Target/Sparc/SparcTargetMachine.cpp =================================================================== --- llvm/lib/Target/Sparc/SparcTargetMachine.cpp +++ llvm/lib/Target/Sparc/SparcTargetMachine.cpp @@ -12,6 +12,7 @@ #include "SparcTargetMachine.h" #include "LeonPasses.h" #include "Sparc.h" +#include "SparcMachineFunctionInfo.h" #include "SparcTargetObjectFile.h" #include "TargetInfo/SparcTargetInfo.h" #include "llvm/CodeGen/Passes.h" @@ -138,6 +139,13 @@ return I.get(); } +MachineFunctionInfo *SparcTargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return SparcMachineFunctionInfo::create(Allocator, + F, STI); +} + namespace { /// Sparc Code Generator Pass Configuration Options. class SparcPassConfig : public TargetPassConfig { Index: llvm/lib/Target/SystemZ/SystemZMachineFunctionInfo.h =================================================================== --- llvm/lib/Target/SystemZ/SystemZMachineFunctionInfo.h +++ llvm/lib/Target/SystemZ/SystemZMachineFunctionInfo.h @@ -37,7 +37,8 @@ unsigned NumLocalDynamics; public: - explicit SystemZMachineFunctionInfo(MachineFunction &MF) + explicit SystemZMachineFunctionInfo(const Function &F, + const TargetSubtargetInfo *STI) : VarArgsFirstGPR(0), VarArgsFirstFPR(0), VarArgsFrameIndex(0), RegSaveFrameIndex(0), FramePointerSaveIndex(0), NumLocalDynamics(0) {} Index: llvm/lib/Target/SystemZ/SystemZTargetMachine.h =================================================================== --- llvm/lib/Target/SystemZ/SystemZTargetMachine.h +++ llvm/lib/Target/SystemZ/SystemZTargetMachine.h @@ -51,6 +51,10 @@ return TLOF.get(); } + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; + bool targetSchedulesPostRAScheduling() const override { return true; }; }; Index: llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp =================================================================== --- llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp +++ llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp @@ -9,6 +9,7 @@ #include "SystemZTargetMachine.h" #include "MCTargetDesc/SystemZMCTargetDesc.h" #include "SystemZ.h" +#include "SystemZMachineFunctionInfo.h" #include "SystemZMachineScheduler.h" #include "SystemZTargetTransformInfo.h" #include "TargetInfo/SystemZTargetInfo.h" @@ -310,3 +311,10 @@ SystemZTargetMachine::getTargetTransformInfo(const Function &F) const { return TargetTransformInfo(SystemZTTIImpl(this, F)); } + +MachineFunctionInfo *SystemZTargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return SystemZMachineFunctionInfo::create( + Allocator, F, STI); +} Index: llvm/lib/Target/VE/VEMachineFunctionInfo.h =================================================================== --- llvm/lib/Target/VE/VEMachineFunctionInfo.h +++ llvm/lib/Target/VE/VEMachineFunctionInfo.h @@ -30,7 +30,8 @@ public: VEMachineFunctionInfo() : VarArgsFrameOffset(0), IsLeafProc(false) {} - explicit VEMachineFunctionInfo(MachineFunction &MF) + explicit VEMachineFunctionInfo(const Function &F, + const TargetSubtargetInfo *STI) : VarArgsFrameOffset(0), IsLeafProc(false) {} MachineFunctionInfo * Index: llvm/lib/Target/VE/VETargetMachine.h =================================================================== --- llvm/lib/Target/VE/VETargetMachine.h +++ llvm/lib/Target/VE/VETargetMachine.h @@ -49,6 +49,10 @@ return TLOF.get(); } + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; + bool isMachineVerifierClean() const override { return false; } TargetTransformInfo getTargetTransformInfo(const Function &F) const override; Index: llvm/lib/Target/VE/VETargetMachine.cpp =================================================================== --- llvm/lib/Target/VE/VETargetMachine.cpp +++ llvm/lib/Target/VE/VETargetMachine.cpp @@ -12,6 +12,7 @@ #include "VETargetMachine.h" #include "TargetInfo/VETargetInfo.h" #include "VE.h" +#include "VEMachineFunctionInfo.h" #include "VETargetTransformInfo.h" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" @@ -98,6 +99,13 @@ return TargetTransformInfo(VETTIImpl(this, F)); } +MachineFunctionInfo *VETargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return VEMachineFunctionInfo::create(Allocator, F, + STI); +} + namespace { /// VE Code Generator Pass Configuration Options. class VEPassConfig : public TargetPassConfig { Index: llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h =================================================================== --- llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h +++ llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h @@ -65,7 +65,8 @@ bool CFGStackified = false; public: - explicit WebAssemblyFunctionInfo(MachineFunction &) {} + explicit WebAssemblyFunctionInfo(const Function &F, + const TargetSubtargetInfo *STI) {} ~WebAssemblyFunctionInfo() override; MachineFunctionInfo * Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h =================================================================== --- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h +++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.h @@ -47,6 +47,10 @@ return TLOF.get(); } + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; + TargetTransformInfo getTargetTransformInfo(const Function &F) const override; bool usesPhysRegsForValues() const override { return false; } Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp =================================================================== --- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -340,6 +340,13 @@ }; } // end anonymous namespace +MachineFunctionInfo *WebAssemblyTargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return WebAssemblyFunctionInfo::create(Allocator, F, + STI); +} + TargetTransformInfo WebAssemblyTargetMachine::getTargetTransformInfo(const Function &F) const { return TargetTransformInfo(WebAssemblyTTIImpl(this, F)); Index: llvm/lib/Target/X86/X86MachineFunctionInfo.h =================================================================== --- llvm/lib/Target/X86/X86MachineFunctionInfo.h +++ llvm/lib/Target/X86/X86MachineFunctionInfo.h @@ -132,8 +132,9 @@ public: X86MachineFunctionInfo() = default; + explicit X86MachineFunctionInfo(const Function &F, + const TargetSubtargetInfo *STI) {} - explicit X86MachineFunctionInfo(MachineFunction &MF) {} explicit X86MachineFunctionInfo(const X86MachineFunctionInfo &) = default; MachineFunctionInfo * Index: llvm/lib/Target/X86/X86TargetMachine.h =================================================================== --- llvm/lib/Target/X86/X86TargetMachine.h +++ llvm/lib/Target/X86/X86TargetMachine.h @@ -54,6 +54,10 @@ return TLOF.get(); } + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; + bool isJIT() const { return IsJIT; } bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const override; Index: llvm/lib/Target/X86/X86TargetMachine.cpp =================================================================== --- llvm/lib/Target/X86/X86TargetMachine.cpp +++ llvm/lib/Target/X86/X86TargetMachine.cpp @@ -16,6 +16,7 @@ #include "X86.h" #include "X86CallLowering.h" #include "X86LegalizerInfo.h" +#include "X86MachineFunctionInfo.h" #include "X86MacroFusion.h" #include "X86Subtarget.h" #include "X86TargetObjectFile.h" @@ -425,6 +426,13 @@ return new X86PassConfig(*this, PM); } +MachineFunctionInfo *X86TargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return X86MachineFunctionInfo::create(Allocator, F, + STI); +} + void X86PassConfig::addIRPasses() { addPass(createAtomicExpandPass()); Index: llvm/lib/Target/XCore/XCoreMachineFunctionInfo.h =================================================================== --- llvm/lib/Target/XCore/XCoreMachineFunctionInfo.h +++ llvm/lib/Target/XCore/XCoreMachineFunctionInfo.h @@ -43,7 +43,8 @@ public: XCoreFunctionInfo() = default; - explicit XCoreFunctionInfo(MachineFunction &MF) {} + explicit XCoreFunctionInfo(const Function &F, + const TargetSubtargetInfo *STI) {} MachineFunctionInfo * clone(BumpPtrAllocator &Allocator, MachineFunction &DestMF, Index: llvm/lib/Target/XCore/XCoreTargetMachine.h =================================================================== --- llvm/lib/Target/XCore/XCoreTargetMachine.h +++ llvm/lib/Target/XCore/XCoreTargetMachine.h @@ -48,6 +48,10 @@ TargetLoweringObjectFile *getObjFileLowering() const override { return TLOF.get(); } + + MachineFunctionInfo * + createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const override; }; } // end namespace llvm Index: llvm/lib/Target/XCore/XCoreTargetMachine.cpp =================================================================== --- llvm/lib/Target/XCore/XCoreTargetMachine.cpp +++ llvm/lib/Target/XCore/XCoreTargetMachine.cpp @@ -13,6 +13,7 @@ #include "MCTargetDesc/XCoreMCTargetDesc.h" #include "TargetInfo/XCoreTargetInfo.h" #include "XCore.h" +#include "XCoreMachineFunctionInfo.h" #include "XCoreTargetObjectFile.h" #include "XCoreTargetTransformInfo.h" #include "llvm/ADT/STLExtras.h" @@ -111,3 +112,9 @@ XCoreTargetMachine::getTargetTransformInfo(const Function &F) const { return TargetTransformInfo(XCoreTTIImpl(this, F)); } + +MachineFunctionInfo *XCoreTargetMachine::createMachineFunctionInfo( + BumpPtrAllocator &Allocator, const Function &F, + const TargetSubtargetInfo *STI) const { + return XCoreFunctionInfo::create(Allocator, F, STI); +}