diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index d48f746805b..3b0c60d35ba 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -100,7 +100,10 @@ public: virtual const TargetSubtargetInfo *getSubtargetImpl() const { return nullptr; } - virtual TargetSubtargetInfo *getSubtargetImpl() { return nullptr; } + virtual TargetSubtargetInfo *getSubtargetImpl() { + const TargetMachine *TM = this; + return const_cast(TM->getSubtargetImpl()); + } mutable TargetOptions Options;