diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index b263c571d9e..d48f746805b 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -100,6 +100,7 @@ public: virtual const TargetSubtargetInfo *getSubtargetImpl() const { return nullptr; } + virtual TargetSubtargetInfo *getSubtargetImpl() { return nullptr; } mutable TargetOptions Options; diff --git a/lib/Target/ARM/ARMTargetMachine.h b/lib/Target/ARM/ARMTargetMachine.h index b72b1df4af8..9a89f8bfe54 100644 --- a/lib/Target/ARM/ARMTargetMachine.h +++ b/lib/Target/ARM/ARMTargetMachine.h @@ -33,6 +33,7 @@ public: bool isLittle); const ARMSubtarget *getSubtargetImpl() const override { return &Subtarget; } + ARMSubtarget *getSubtargetImpl() override { return &Subtarget; } const ARMBaseRegisterInfo *getRegisterInfo() const override { return getSubtargetImpl()->getRegisterInfo(); } @@ -54,7 +55,7 @@ public: const DataLayout *getDataLayout() const override { return getSubtargetImpl()->getDataLayout(); } - ARMJITInfo *getJITInfo() override { return Subtarget.getJITInfo(); } + ARMJITInfo *getJITInfo() override { return getSubtargetImpl()->getJITInfo(); } /// \brief Register ARM analysis passes with a pass manager. void addAnalysisPasses(PassManagerBase &PM) override; diff --git a/lib/Target/Mips/MipsTargetMachine.h b/lib/Target/Mips/MipsTargetMachine.h index bcf411f9cd6..1651457dd7c 100644 --- a/lib/Target/Mips/MipsTargetMachine.h +++ b/lib/Target/Mips/MipsTargetMachine.h @@ -50,13 +50,18 @@ public: return Subtarget; return &DefaultSubtarget; } + MipsSubtarget *getSubtargetImpl() override { + if (Subtarget) + return Subtarget; + return &DefaultSubtarget; + } const InstrItineraryData *getInstrItineraryData() const override { return Subtarget->inMips16Mode() ? nullptr : &getSubtargetImpl()->getInstrItineraryData(); } MipsJITInfo *getJITInfo() override { - return Subtarget->getJITInfo(); + return getSubtargetImpl()->getJITInfo(); } const MipsRegisterInfo *getRegisterInfo() const override { return getSubtargetImpl()->getRegisterInfo(); diff --git a/lib/Target/PowerPC/PPCTargetMachine.h b/lib/Target/PowerPC/PPCTargetMachine.h index 4c7029ca7a3..e11b4681dbd 100644 --- a/lib/Target/PowerPC/PPCTargetMachine.h +++ b/lib/Target/PowerPC/PPCTargetMachine.h @@ -38,7 +38,7 @@ public: const PPCFrameLowering *getFrameLowering() const override { return getSubtargetImpl()->getFrameLowering(); } - PPCJITInfo *getJITInfo() override { return Subtarget.getJITInfo(); } + PPCJITInfo *getJITInfo() override { return getSubtargetImpl()->getJITInfo(); } const PPCTargetLowering *getTargetLowering() const override { return getSubtargetImpl()->getTargetLowering(); } @@ -53,6 +53,7 @@ public: return getSubtargetImpl()->getDataLayout(); } const PPCSubtarget *getSubtargetImpl() const override { return &Subtarget; } + PPCSubtarget *getSubtargetImpl() override { return &Subtarget; } const InstrItineraryData *getInstrItineraryData() const override { return &getSubtargetImpl()->getInstrItineraryData(); } diff --git a/lib/Target/Sparc/SparcTargetMachine.h b/lib/Target/Sparc/SparcTargetMachine.h index 03b513746df..d5fb272a128 100644 --- a/lib/Target/Sparc/SparcTargetMachine.h +++ b/lib/Target/Sparc/SparcTargetMachine.h @@ -35,6 +35,7 @@ public: return getSubtargetImpl()->getFrameLowering(); } const SparcSubtarget *getSubtargetImpl() const override { return &Subtarget; } + SparcSubtarget *getSubtargetImpl() override { return &Subtarget; } const SparcRegisterInfo *getRegisterInfo() const override { return getSubtargetImpl()->getRegisterInfo(); } @@ -44,7 +45,9 @@ public: const SparcSelectionDAGInfo *getSelectionDAGInfo() const override { return getSubtargetImpl()->getSelectionDAGInfo(); } - SparcJITInfo *getJITInfo() override { return Subtarget.getJITInfo(); } + SparcJITInfo *getJITInfo() override { + return getSubtargetImpl()->getJITInfo(); + } const DataLayout *getDataLayout() const override { return getSubtargetImpl()->getDataLayout(); } diff --git a/lib/Target/X86/X86TargetMachine.h b/lib/Target/X86/X86TargetMachine.h index 41d51570b9a..9fccbe2b072 100644 --- a/lib/Target/X86/X86TargetMachine.h +++ b/lib/Target/X86/X86TargetMachine.h @@ -41,8 +41,9 @@ public: const TargetFrameLowering *getFrameLowering() const override { return getSubtargetImpl()->getFrameLowering(); } - X86JITInfo *getJITInfo() override { return Subtarget.getJITInfo(); } + X86JITInfo *getJITInfo() override { return getSubtargetImpl()->getJITInfo(); } const X86Subtarget *getSubtargetImpl() const override { return &Subtarget; } + X86Subtarget *getSubtargetImpl() override { return &Subtarget; } const X86TargetLowering *getTargetLowering() const override { return getSubtargetImpl()->getTargetLowering(); }