]> granicus.if.org Git - llvm/commitdiff
Object: Add IRObjectFile::getTargetTriple().
authorPeter Collingbourne <peter@pcc.me.uk>
Thu, 24 Nov 2016 01:13:09 +0000 (01:13 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Thu, 24 Nov 2016 01:13:09 +0000 (01:13 +0000)
This lets us remove a use of IRObjectFile::getModule() in llvm-nm.

Differential Revision: https://reviews.llvm.org/D27074

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287846 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Object/IRObjectFile.h
lib/Object/IRObjectFile.cpp
tools/llvm-nm/llvm-nm.cpp

index 5126ea10da765a2502fb43669890a0dc6d85edfb..9acc286a6a0ebbf038d18cafb3382d0d18df4b89 100644 (file)
@@ -60,6 +60,8 @@ public:
   }
   std::unique_ptr<Module> takeModule();
 
+  StringRef getTargetTriple() const;
+
   static inline bool classof(const Binary *v) {
     return v->isIR();
   }
index 4fd5e64fb7c1a5fdff0da4367265fea736d95342..51b2446535b7fd59b638c219ab938587a646227f 100644 (file)
@@ -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<MemoryBufferRef> IRObjectFile::findBitcodeInObject(const ObjectFile &Obj) {
   for (const SectionRef &Sec : Obj.sections()) {
     if (Sec.isBitcode()) {
index 8c6fa4ecec70ed7f120b214e7e689335bba61905..436cf9cac6820bc033dcf7070e81ae4f4ea43481 100644 (file)
@@ -265,14 +265,8 @@ static bool compareSymbolName(const NMSymbol &A, const NMSymbol &B) {
 }
 
 static char isSymbolList64Bit(SymbolicFile &Obj) {
-  if (isa<IRObjectFile>(Obj)) {
-    IRObjectFile *IRobj = dyn_cast<IRObjectFile>(&Obj);
-    Module &M = IRobj->getModule();
-    if (M.getTargetTriple().empty())
-      return false;
-    Triple T(M.getTargetTriple());
-    return T.isArch64Bit();
-  }
+  if (auto *IRObj = dyn_cast<IRObjectFile>(&Obj))
+    return Triple(IRObj->getTargetTriple()).isArch64Bit();
   if (isa<COFFObjectFile>(Obj))
     return false;
   if (MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj))