Add out of line virtual destructors to all LLVMTargetMachine subclasses

These recently all grew a unique_ptr<TargetLoweringObjectFile> member in
r221878.  When anyone calls a virtual method of a class, clang-cl
requires all virtual methods to be semantically valid. This includes the
implicit virtual destructor, which triggers instantiation of the
unique_ptr destructor, which fails because the type being deleted is
incomplete.

This is just part of the ongoing saga of PR20337, which is affecting
Blink as well. Because the MSVC ABI doesn't have key functions, we end
up referencing the vtable and implicit destructor on any virtual call
through a class. We don't actually end up emitting the dtor, so it'd be
good if we could avoid this unneeded type completion work.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222480 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Kleckner
2014-11-20 23:37:18 +00:00
parent 10754c251b
commit d12434058d
22 changed files with 37 additions and 3 deletions

View File

@@ -117,6 +117,8 @@ AArch64TargetMachine::AArch64TargetMachine(const Target &T, StringRef TT,
initAsmInfo(); initAsmInfo();
} }
AArch64TargetMachine::~AArch64TargetMachine() {}
const AArch64Subtarget * const AArch64Subtarget *
AArch64TargetMachine::getSubtargetImpl(const Function &F) const { AArch64TargetMachine::getSubtargetImpl(const Function &F) const {
AttributeSet FnAttrs = F.getAttributes(); AttributeSet FnAttrs = F.getAttributes();

View File

@@ -33,6 +33,8 @@ public:
Reloc::Model RM, CodeModel::Model CM, Reloc::Model RM, CodeModel::Model CM,
CodeGenOpt::Level OL, bool IsLittleEndian); CodeGenOpt::Level OL, bool IsLittleEndian);
~AArch64TargetMachine() override;
const AArch64Subtarget *getSubtargetImpl() const override { const AArch64Subtarget *getSubtargetImpl() const override {
return &Subtarget; return &Subtarget;
} }

View File

@@ -69,6 +69,8 @@ ARMBaseTargetMachine::ARMBaseTargetMachine(const Target &T, StringRef TT,
Subtarget.isTargetHardFloat() ? FloatABI::Hard : FloatABI::Soft; Subtarget.isTargetHardFloat() ? FloatABI::Hard : FloatABI::Soft;
} }
ARMBaseTargetMachine::~ARMBaseTargetMachine() {}
const ARMSubtarget * const ARMSubtarget *
ARMBaseTargetMachine::getSubtargetImpl(const Function &F) const { ARMBaseTargetMachine::getSubtargetImpl(const Function &F) const {
AttributeSet FnAttrs = F.getAttributes(); AttributeSet FnAttrs = F.getAttributes();

View File

@@ -35,6 +35,7 @@ public:
Reloc::Model RM, CodeModel::Model CM, Reloc::Model RM, CodeModel::Model CM,
CodeGenOpt::Level OL, CodeGenOpt::Level OL,
bool isLittle); bool isLittle);
~ARMBaseTargetMachine() override;
const ARMSubtarget *getSubtargetImpl() const override { return &Subtarget; } const ARMSubtarget *getSubtargetImpl() const override { return &Subtarget; }
const ARMSubtarget *getSubtargetImpl(const Function &F) const override; const ARMSubtarget *getSubtargetImpl(const Function &F) const override;

View File

@@ -75,6 +75,8 @@ HexagonTargetMachine::HexagonTargetMachine(const Target &T, StringRef TT,
initAsmInfo(); initAsmInfo();
} }
HexagonTargetMachine::~HexagonTargetMachine() {}
namespace { namespace {
/// Hexagon Code Generator Pass Configuration Options. /// Hexagon Code Generator Pass Configuration Options.
class HexagonPassConfig : public TargetPassConfig { class HexagonPassConfig : public TargetPassConfig {

View File

@@ -31,6 +31,7 @@ public:
StringRef FS, const TargetOptions &Options, StringRef FS, const TargetOptions &Options,
Reloc::Model RM, CodeModel::Model CM, Reloc::Model RM, CodeModel::Model CM,
CodeGenOpt::Level OL); CodeGenOpt::Level OL);
~HexagonTargetMachine() override;
const HexagonSubtarget *getSubtargetImpl() const override { const HexagonSubtarget *getSubtargetImpl() const override {
return &Subtarget; return &Subtarget;

View File

@@ -36,6 +36,8 @@ MSP430TargetMachine::MSP430TargetMachine(const Target &T, StringRef TT,
initAsmInfo(); initAsmInfo();
} }
MSP430TargetMachine::~MSP430TargetMachine() {}
namespace { namespace {
/// MSP430 Code Generator Pass Configuration Options. /// MSP430 Code Generator Pass Configuration Options.
class MSP430PassConfig : public TargetPassConfig { class MSP430PassConfig : public TargetPassConfig {

View File

@@ -32,6 +32,7 @@ public:
StringRef CPU, StringRef FS, const TargetOptions &Options, StringRef CPU, StringRef FS, const TargetOptions &Options,
Reloc::Model RM, CodeModel::Model CM, Reloc::Model RM, CodeModel::Model CM,
CodeGenOpt::Level OL); CodeGenOpt::Level OL);
~MSP430TargetMachine() override;
const MSP430Subtarget *getSubtargetImpl() const override { const MSP430Subtarget *getSubtargetImpl() const override {
return &Subtarget; return &Subtarget;

View File

@@ -69,6 +69,8 @@ MipsTargetMachine::MipsTargetMachine(const Target &T, StringRef TT,
initAsmInfo(); initAsmInfo();
} }
MipsTargetMachine::~MipsTargetMachine() {}
void MipsebTargetMachine::anchor() { } void MipsebTargetMachine::anchor() { }
MipsebTargetMachine:: MipsebTargetMachine::

View File

@@ -38,6 +38,7 @@ public:
MipsTargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS, MipsTargetMachine(const Target &T, StringRef TT, StringRef CPU, StringRef FS,
const TargetOptions &Options, Reloc::Model RM, const TargetOptions &Options, Reloc::Model RM,
CodeModel::Model CM, CodeGenOpt::Level OL, bool isLittle); CodeModel::Model CM, CodeGenOpt::Level OL, bool isLittle);
~MipsTargetMachine() override;
void addAnalysisPasses(PassManagerBase &PM) override; void addAnalysisPasses(PassManagerBase &PM) override;

View File

@@ -80,6 +80,8 @@ NVPTXTargetMachine::NVPTXTargetMachine(const Target &T, StringRef TT,
initAsmInfo(); initAsmInfo();
} }
NVPTXTargetMachine::~NVPTXTargetMachine() {}
void NVPTXTargetMachine32::anchor() {} void NVPTXTargetMachine32::anchor() {}
NVPTXTargetMachine32::NVPTXTargetMachine32( NVPTXTargetMachine32::NVPTXTargetMachine32(

View File

@@ -36,6 +36,8 @@ public:
const TargetOptions &Options, Reloc::Model RM, const TargetOptions &Options, Reloc::Model RM,
CodeModel::Model CM, CodeGenOpt::Level OP, bool is64bit); CodeModel::Model CM, CodeGenOpt::Level OP, bool is64bit);
~NVPTXTargetMachine() override;
const NVPTXSubtarget *getSubtargetImpl() const override { return &Subtarget; } const NVPTXSubtarget *getSubtargetImpl() const override { return &Subtarget; }
ManagedStringPool *getManagedStrPool() const { ManagedStringPool *getManagedStrPool() const {

View File

@@ -85,6 +85,8 @@ PPCTargetMachine::PPCTargetMachine(const Target &T, StringRef TT, StringRef CPU,
initAsmInfo(); initAsmInfo();
} }
PPCTargetMachine::~PPCTargetMachine() {}
void PPC32TargetMachine::anchor() { } void PPC32TargetMachine::anchor() { }
PPC32TargetMachine::PPC32TargetMachine(const Target &T, StringRef TT, PPC32TargetMachine::PPC32TargetMachine(const Target &T, StringRef TT,

View File

@@ -35,6 +35,8 @@ public:
Reloc::Model RM, CodeModel::Model CM, Reloc::Model RM, CodeModel::Model CM,
CodeGenOpt::Level OL); CodeGenOpt::Level OL);
~PPCTargetMachine() override;
const PPCSubtarget *getSubtargetImpl() const override { return &Subtarget; } const PPCSubtarget *getSubtargetImpl() const override { return &Subtarget; }
const PPCSubtarget *getSubtargetImpl(const Function &F) const override; const PPCSubtarget *getSubtargetImpl(const Function &F) const override;

View File

@@ -38,6 +38,8 @@ SparcTargetMachine::SparcTargetMachine(const Target &T, StringRef TT,
initAsmInfo(); initAsmInfo();
} }
SparcTargetMachine::~SparcTargetMachine() {}
namespace { namespace {
/// Sparc Code Generator Pass Configuration Options. /// Sparc Code Generator Pass Configuration Options.
class SparcPassConfig : public TargetPassConfig { class SparcPassConfig : public TargetPassConfig {

View File

@@ -28,6 +28,7 @@ public:
StringRef CPU, StringRef FS, const TargetOptions &Options, StringRef CPU, StringRef FS, const TargetOptions &Options,
Reloc::Model RM, CodeModel::Model CM, Reloc::Model RM, CodeModel::Model CM,
CodeGenOpt::Level OL, bool is64bit); CodeGenOpt::Level OL, bool is64bit);
~SparcTargetMachine() override;
const SparcSubtarget *getSubtargetImpl() const override { return &Subtarget; } const SparcSubtarget *getSubtargetImpl() const override { return &Subtarget; }

View File

@@ -31,6 +31,8 @@ SystemZTargetMachine::SystemZTargetMachine(const Target &T, StringRef TT,
initAsmInfo(); initAsmInfo();
} }
SystemZTargetMachine::~SystemZTargetMachine() {}
namespace { namespace {
/// SystemZ Code Generator Pass Configuration Options. /// SystemZ Code Generator Pass Configuration Options.
class SystemZPassConfig : public TargetPassConfig { class SystemZPassConfig : public TargetPassConfig {

View File

@@ -31,6 +31,7 @@ public:
StringRef FS, const TargetOptions &Options, StringRef FS, const TargetOptions &Options,
Reloc::Model RM, CodeModel::Model CM, Reloc::Model RM, CodeModel::Model CM,
CodeGenOpt::Level OL); CodeGenOpt::Level OL);
~SystemZTargetMachine() override;
// Override TargetMachine. // Override TargetMachine.
const SystemZSubtarget *getSubtargetImpl() const override { const SystemZSubtarget *getSubtargetImpl() const override {

View File

@@ -29,8 +29,6 @@ extern "C" void LLVMInitializeX86Target() {
RegisterTargetMachine<X86TargetMachine> Y(TheX86_64Target); RegisterTargetMachine<X86TargetMachine> Y(TheX86_64Target);
} }
void X86TargetMachine::anchor() { }
static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) { static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
if (TT.isOSBinFormatMachO()) { if (TT.isOSBinFormatMachO()) {
if (TT.getArch() == Triple::x86_64) if (TT.getArch() == Triple::x86_64)
@@ -72,6 +70,8 @@ X86TargetMachine::X86TargetMachine(const Target &T, StringRef TT, StringRef CPU,
initAsmInfo(); initAsmInfo();
} }
X86TargetMachine::~X86TargetMachine() {}
const X86Subtarget * const X86Subtarget *
X86TargetMachine::getSubtargetImpl(const Function &F) const { X86TargetMachine::getSubtargetImpl(const Function &F) const {
AttributeSet FnAttrs = F.getAttributes(); AttributeSet FnAttrs = F.getAttributes();

View File

@@ -23,7 +23,6 @@ namespace llvm {
class StringRef; class StringRef;
class X86TargetMachine final : public LLVMTargetMachine { class X86TargetMachine final : public LLVMTargetMachine {
virtual void anchor();
std::unique_ptr<TargetLoweringObjectFile> TLOF; std::unique_ptr<TargetLoweringObjectFile> TLOF;
X86Subtarget Subtarget; X86Subtarget Subtarget;
@@ -34,6 +33,8 @@ public:
StringRef CPU, StringRef FS, const TargetOptions &Options, StringRef CPU, StringRef FS, const TargetOptions &Options,
Reloc::Model RM, CodeModel::Model CM, Reloc::Model RM, CodeModel::Model CM,
CodeGenOpt::Level OL); CodeGenOpt::Level OL);
~X86TargetMachine() override;
const X86Subtarget *getSubtargetImpl() const override { return &Subtarget; } const X86Subtarget *getSubtargetImpl() const override { return &Subtarget; }
const X86Subtarget *getSubtargetImpl(const Function &F) const override; const X86Subtarget *getSubtargetImpl(const Function &F) const override;

View File

@@ -32,6 +32,8 @@ XCoreTargetMachine::XCoreTargetMachine(const Target &T, StringRef TT,
initAsmInfo(); initAsmInfo();
} }
XCoreTargetMachine::~XCoreTargetMachine() {}
namespace { namespace {
/// XCore Code Generator Pass Configuration Options. /// XCore Code Generator Pass Configuration Options.
class XCorePassConfig : public TargetPassConfig { class XCorePassConfig : public TargetPassConfig {

View File

@@ -27,6 +27,7 @@ public:
StringRef CPU, StringRef FS, const TargetOptions &Options, StringRef CPU, StringRef FS, const TargetOptions &Options,
Reloc::Model RM, CodeModel::Model CM, Reloc::Model RM, CodeModel::Model CM,
CodeGenOpt::Level OL); CodeGenOpt::Level OL);
~XCoreTargetMachine() override;
const XCoreSubtarget *getSubtargetImpl() const override { return &Subtarget; } const XCoreSubtarget *getSubtargetImpl() const override { return &Subtarget; }