diff --git a/src/core/util/llvmdisassembler/LLVMtoFailTranslator.hpp b/src/core/util/llvmdisassembler/LLVMtoFailTranslator.hpp index 4e9444c2..5849e12c 100644 --- a/src/core/util/llvmdisassembler/LLVMtoFailTranslator.hpp +++ b/src/core/util/llvmdisassembler/LLVMtoFailTranslator.hpp @@ -13,6 +13,12 @@ namespace fail { */ class LLVMtoFailTranslator { public: + /** + * Maps registers to/from linear addresses usable for def/use-pruning + * purposes and storage in the database. Takes care that the linear + * addresses of x86 subregisters (e.g., AX represents the lower 16 bits of + * EAX) overlap with their siblings. + */ struct reginfo_t { int id; regwidth_t width; @@ -20,18 +26,17 @@ public: byte_t offset; int toDataAddress() const { - // .. 5 4 | 7 6 5 4 | 3 2 1 0 - // | | - return (id << 8) | ((width/8) << 4) | (offset / 8); + // .. 5 4 | 3 2 1 0 + // | + return (id << 4) | (offset / 8); } + // does not recreate width or mask static reginfo_t fromDataAddress(int addr) { - int id = addr >> 8; - regwidth_t width = ((addr >> 4) & 0xf) * 8; - byte_t offset = (addr & 0xf) * 8; - return reginfo_t(id, width, offset); + int id = addr >> 4; + byte_t offset = (addr & 0xf) * 8; + return reginfo_t(id, 0, offset); } - reginfo_t(int id=-1, regwidth_t width = 32, byte_t offs = 0) : id(id), width(width), mask((regwidth_t)((((long long)1 << width) - 1) << offs)), offset(offs) {}; }; diff --git a/tools/import-trace/RegisterImporter.cc b/tools/import-trace/RegisterImporter.cc index 6b44969e..5564a184 100644 --- a/tools/import-trace/RegisterImporter.cc +++ b/tools/import-trace/RegisterImporter.cc @@ -33,9 +33,8 @@ bool RegisterImporter::addRegisterTrace(simtime_t curtime, instruction_count_t i const Trace_Event &ev, const LLVMtoFailTranslator::reginfo_t &info, char access_type) { - LLVMtoFailTranslator::reginfo_t one_byte_window = info; - one_byte_window.width = 8; - address_t from = one_byte_window.toDataAddress(), to = one_byte_window.toDataAddress() + (info.width) / 8; + address_t from = info.toDataAddress(); + address_t to = from + info.width / 8; // Iterate over all accessed bytes for (address_t data_address = from; data_address < to; ++data_address) {