diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index dcd454e8949..22d01bfc846 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -101,7 +101,7 @@ public: virtual const TargetSubtargetInfo *getSubtargetImpl() const { return nullptr; } - virtual TargetSubtargetInfo *getSubtargetImpl() { + TargetSubtargetInfo *getSubtargetImpl() { const TargetMachine *TM = this; return const_cast(TM->getSubtargetImpl()); } diff --git a/lib/Target/ARM/ARMTargetMachine.h b/lib/Target/ARM/ARMTargetMachine.h index ae98c21e4b4..8b559682211 100644 --- a/lib/Target/ARM/ARMTargetMachine.h +++ b/lib/Target/ARM/ARMTargetMachine.h @@ -33,7 +33,6 @@ public: bool isLittle); const ARMSubtarget *getSubtargetImpl() const override { return &Subtarget; } - ARMSubtarget *getSubtargetImpl() override { return &Subtarget; } /// \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 6d53274c18a..eefd96ab4ae 100644 --- a/lib/Target/Mips/MipsTargetMachine.h +++ b/lib/Target/Mips/MipsTargetMachine.h @@ -44,10 +44,8 @@ public: return Subtarget; return &DefaultSubtarget; } - MipsSubtarget *getSubtargetImpl() override { - if (Subtarget) - return Subtarget; - return &DefaultSubtarget; + MipsSubtarget *getSubtargetImpl() { + return static_cast(TargetMachine::getSubtargetImpl()); } /// \brief Reset the subtarget for the Mips target. diff --git a/lib/Target/PowerPC/PPCTargetMachine.h b/lib/Target/PowerPC/PPCTargetMachine.h index 653615aeadd..9bda22a354d 100644 --- a/lib/Target/PowerPC/PPCTargetMachine.h +++ b/lib/Target/PowerPC/PPCTargetMachine.h @@ -33,7 +33,6 @@ public: CodeGenOpt::Level OL, bool is64Bit); const PPCSubtarget *getSubtargetImpl() const override { return &Subtarget; } - PPCSubtarget *getSubtargetImpl() override { return &Subtarget; } // Pass Pipeline Configuration TargetPassConfig *createPassConfig(PassManagerBase &PM) override; diff --git a/lib/Target/Sparc/SparcTargetMachine.h b/lib/Target/Sparc/SparcTargetMachine.h index 2e0c778464d..62f088b1481 100644 --- a/lib/Target/Sparc/SparcTargetMachine.h +++ b/lib/Target/Sparc/SparcTargetMachine.h @@ -29,7 +29,10 @@ public: CodeGenOpt::Level OL, bool is64bit); const SparcSubtarget *getSubtargetImpl() const override { return &Subtarget; } - SparcSubtarget *getSubtargetImpl() override { return &Subtarget; } + + SparcSubtarget *getSubtargetImpl() { + return static_cast(TargetMachine::getSubtargetImpl()); + } // Pass Pipeline Configuration TargetPassConfig *createPassConfig(PassManagerBase &PM) override; diff --git a/lib/Target/X86/X86TargetMachine.h b/lib/Target/X86/X86TargetMachine.h index 4bdb5084075..633c5710315 100644 --- a/lib/Target/X86/X86TargetMachine.h +++ b/lib/Target/X86/X86TargetMachine.h @@ -32,7 +32,10 @@ public: Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL); const X86Subtarget *getSubtargetImpl() const override { return &Subtarget; } - X86Subtarget *getSubtargetImpl() override { return &Subtarget; } + + X86Subtarget *getSubtargetImpl() { + return static_cast(TargetMachine::getSubtargetImpl()); + } /// \brief Register X86 analysis passes with a pass manager. void addAnalysisPasses(PassManagerBase &PM) override;