diff options
Diffstat (limited to 'llvm/lib/LTO/LTOModule.cpp')
-rw-r--r-- | llvm/lib/LTO/LTOModule.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/LTO/LTOModule.cpp b/llvm/lib/LTO/LTOModule.cpp index 155790041a75..4cc1b307c553 100644 --- a/llvm/lib/LTO/LTOModule.cpp +++ b/llvm/lib/LTO/LTOModule.cpp @@ -27,6 +27,7 @@ #include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCSymbol.h" #include "llvm/MC/SubtargetFeature.h" +#include "llvm/MC/TargetRegistry.h" #include "llvm/Object/IRObjectFile.h" #include "llvm/Object/MachO.h" #include "llvm/Object/ObjectFile.h" @@ -35,7 +36,6 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/SourceMgr.h" -#include "llvm/Support/TargetRegistry.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Transforms/Utils/GlobalStatus.h" @@ -688,3 +688,16 @@ Expected<uint32_t> LTOModule::getMachOCPUType() const { Expected<uint32_t> LTOModule::getMachOCPUSubType() const { return MachO::getCPUSubType(Triple(Mod->getTargetTriple())); } + +bool LTOModule::hasCtorDtor() const { + for (auto Sym : SymTab.symbols()) { + if (auto *GV = Sym.dyn_cast<GlobalValue *>()) { + StringRef Name = GV->getName(); + if (Name.consume_front("llvm.global_")) { + if (Name.equals("ctors") || Name.equals("dtors")) + return true; + } + } + } + return false; +} |