diff --git a/src/core/util/llvmdisassembler/LLVMDisassembler.cpp b/src/core/util/llvmdisassembler/LLVMDisassembler.cpp index bb42b002..146d092c 100644 --- a/src/core/util/llvmdisassembler/LLVMDisassembler.cpp +++ b/src/core/util/llvmdisassembler/LLVMDisassembler.cpp @@ -15,8 +15,6 @@ static std::ostream& operator<<(std::ostream& stream, const llvm::StringRef& s) LLVMtoFailTranslator *LLVMDisassembler::getTranslator() { if (ltofail == 0) { - std::cout << "ArchType: " << llvm::Triple::getArchTypeName( llvm::Triple::ArchType(object->getArch()) ) << std::endl; - switch ( llvm::Triple::ArchType(object->getArch()) ) { case llvm::Triple::x86: case llvm::Triple::x86_64: @@ -26,7 +24,9 @@ LLVMtoFailTranslator *LLVMDisassembler::getTranslator() { ltofail = new LLVMtoFailGem5(this); break; default: - std::cout << " not supported :("; + std::cerr << "ArchType " + << llvm::Triple::getArchTypeName(llvm::Triple::ArchType(object->getArch())) + << " not supported\n"; exit(1); } } diff --git a/tools/import-trace/RegisterImporter.cc b/tools/import-trace/RegisterImporter.cc index 48cb144d..2d3e14ad 100644 --- a/tools/import-trace/RegisterImporter.cc +++ b/tools/import-trace/RegisterImporter.cc @@ -182,9 +182,9 @@ bool RegisterImporter::handle_ip_event(fail::simtime_t curtime, instruction_coun it != opcode.reg_uses.end(); ++it) { const LLVMtoFailTranslator::reginfo_t &info = m_ltof->getFailRegisterInfo(*it); if (&info == &m_ltof->notfound) { - LOG << "Could not find a mapping for LLVM input register #" << std::dec << *it - << " at IP " << std::hex << ev.ip() - << ", skipping" << std::endl; + // record failed translation, report later + m_regnotfound[*it].count++; + m_regnotfound[*it].address.insert(ev.ip()); continue; } @@ -202,9 +202,9 @@ bool RegisterImporter::handle_ip_event(fail::simtime_t curtime, instruction_coun it != opcode.reg_defs.end(); ++it) { const LLVMtoFailTranslator::reginfo_t &info = m_ltof->getFailRegisterInfo(*it); if (&info == &m_ltof->notfound) { - LOG << "Could not find a mapping for LLVM output register #" << std::dec << *it - << " at IP " << std::hex << ev.ip() - << ", skipping" << std::endl; + // record failed translation, report later + m_regnotfound[*it].count++; + m_regnotfound[*it].address.insert(ev.ip()); continue; } @@ -219,3 +219,30 @@ bool RegisterImporter::handle_ip_event(fail::simtime_t curtime, instruction_coun return true; } + +bool RegisterImporter::trace_end_reached() +{ + // report failed LLVM -> FAIL* register mappings, if any + if (m_regnotfound.empty()) { + return true; + } + + LOG << "WARNING: Some LLVM -> FAIL* register mappings failed during import, these will not be injected into:" << std::endl; + for (auto it = m_regnotfound.cbegin(); it != m_regnotfound.cend(); ++it) { + const LLVMDisassembler::register_t id = it->first; + const RegNotFound& rnf = it->second; + LOG << "LLVM register " << std::dec << id + << " \"" << disas->getRegisterInfo().getName(id) << "\": " + << "seen " << rnf.count << " times in the trace" << std::endl; + std::ostream& o = LOG << " corresponding instruction addresses in ELF binary: " << std::hex; + for (auto addr_it = rnf.address.cbegin(); addr_it != rnf.address.cend(); ++addr_it) { + if (addr_it != rnf.address.cbegin()) { + o << ", "; + } + o << "0x" << *addr_it; + } + o << std::endl; + } + + return true; +} diff --git a/tools/import-trace/RegisterImporter.hpp b/tools/import-trace/RegisterImporter.hpp index 377c9a82..64218097 100644 --- a/tools/import-trace/RegisterImporter.hpp +++ b/tools/import-trace/RegisterImporter.hpp @@ -24,6 +24,15 @@ class RegisterImporter : public Importer { std::set m_register_ids; unsigned m_ip_register_id; + // Data structures for recording failed LLVM -> FAIL* register mappings, + // including occurrence counts in the trace (to give an estimate on the + // impact) and instruction addresses (for debugging purposes). + struct RegNotFound { + uint64_t count = 0; + std::set address; + }; + std::map m_regnotfound; + public: RegisterImporter() : Importer(), do_gp(true), do_flags(false), do_ip(false), do_split_registers(true), m_ip_register_id(0) {} @@ -42,6 +51,8 @@ protected: return true; } + virtual bool trace_end_reached(); + virtual void open_unused_ec_intervals() { /* empty, Memory Map has a different meaning in this importer */ }