Skip to content

Commit

Permalink
Object: Add IRObjectFile::getTargetTriple().
Browse files Browse the repository at this point in the history
This lets us remove a use of IRObjectFile::getModule() in llvm-nm.

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

llvm-svn: 287846
  • Loading branch information
pcc committed Nov 24, 2016
1 parent e32baa0 commit debb6f6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 2 additions & 0 deletions llvm/include/llvm/Object/IRObjectFile.h
Expand Up @@ -60,6 +60,8 @@ class IRObjectFile : public SymbolicFile {
}
std::unique_ptr<Module> takeModule();

StringRef getTargetTriple() const;

static inline bool classof(const Binary *v) {
return v->isIR();
}
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Object/IRObjectFile.cpp
Expand Up @@ -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()) {
Expand Down
10 changes: 2 additions & 8 deletions llvm/tools/llvm-nm/llvm-nm.cpp
Expand Up @@ -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))
Expand Down

0 comments on commit debb6f6

Please sign in to comment.