diff --git a/llvm/include/llvm/Object/IRObjectFile.h b/llvm/include/llvm/Object/IRObjectFile.h index 5126ea10da76..9acc286a6a0e 100644 --- a/llvm/include/llvm/Object/IRObjectFile.h +++ b/llvm/include/llvm/Object/IRObjectFile.h @@ -60,6 +60,8 @@ public: } std::unique_ptr takeModule(); + StringRef getTargetTriple() const; + static inline bool classof(const Binary *v) { return v->isIR(); } diff --git a/llvm/lib/Object/IRObjectFile.cpp b/llvm/lib/Object/IRObjectFile.cpp index 4fd5e64fb7c1..51b2446535b7 100644 --- a/llvm/lib/Object/IRObjectFile.cpp +++ b/llvm/lib/Object/IRObjectFile.cpp @@ -213,6 +213,8 @@ basic_symbol_iterator IRObjectFile::symbol_end() const { return basic_symbol_iterator(BasicSymbolRef(Ret, this)); } +StringRef IRObjectFile::getTargetTriple() const { return M->getTargetTriple(); } + ErrorOr IRObjectFile::findBitcodeInObject(const ObjectFile &Obj) { for (const SectionRef &Sec : Obj.sections()) { if (Sec.isBitcode()) { diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp index 8c6fa4ecec70..436cf9cac682 100644 --- a/llvm/tools/llvm-nm/llvm-nm.cpp +++ b/llvm/tools/llvm-nm/llvm-nm.cpp @@ -265,14 +265,8 @@ static bool compareSymbolName(const NMSymbol &A, const NMSymbol &B) { } static char isSymbolList64Bit(SymbolicFile &Obj) { - if (isa(Obj)) { - IRObjectFile *IRobj = dyn_cast(&Obj); - Module &M = IRobj->getModule(); - if (M.getTargetTriple().empty()) - return false; - Triple T(M.getTargetTriple()); - return T.isArch64Bit(); - } + if (auto *IRObj = dyn_cast(&Obj)) + return Triple(IRObj->getTargetTriple()).isArch64Bit(); if (isa(Obj)) return false; if (MachOObjectFile *MachO = dyn_cast(&Obj))