[llvm] r287846 - Object: Add IRObjectFile::getTargetTriple().

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 23 17:13:09 PST 2016


Author: pcc
Date: Wed Nov 23 19:13:09 2016
New Revision: 287846

URL: http://llvm.org/viewvc/llvm-project?rev=287846&view=rev
Log:
Object: Add IRObjectFile::getTargetTriple().

This lets us remove a use of IRObjectFile::getModule() in llvm-nm.

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

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

Modified: llvm/trunk/include/llvm/Object/IRObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/IRObjectFile.h?rev=287846&r1=287845&r2=287846&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/IRObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/IRObjectFile.h Wed Nov 23 19:13:09 2016
@@ -60,6 +60,8 @@ public:
   }
   std::unique_ptr<Module> takeModule();
 
+  StringRef getTargetTriple() const;
+
   static inline bool classof(const Binary *v) {
     return v->isIR();
   }

Modified: llvm/trunk/lib/Object/IRObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/IRObjectFile.cpp?rev=287846&r1=287845&r2=287846&view=diff
==============================================================================
--- llvm/trunk/lib/Object/IRObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/IRObjectFile.cpp Wed Nov 23 19:13:09 2016
@@ -213,6 +213,8 @@ basic_symbol_iterator IRObjectFile::symb
   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()) {

Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=287846&r1=287845&r2=287846&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Wed Nov 23 19:13:09 2016
@@ -265,14 +265,8 @@ static bool compareSymbolName(const NMSy
 }
 
 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))




More information about the llvm-commits mailing list