Index: lib/Target/X86/Disassembler/X86Disassembler.cpp =================================================================== --- lib/Target/X86/Disassembler/X86Disassembler.cpp +++ lib/Target/X86/Disassembler/X86Disassembler.cpp @@ -96,25 +96,17 @@ } } -struct Region { - ArrayRef Bytes; - uint64_t Base; - Region(ArrayRef Bytes, uint64_t Base) : Bytes(Bytes), Base(Base) {} -}; - -/// A callback function that wraps the readByte method from Region. +/// A callback function that wraps the readByte method from an ArrayRef /// /// @param Arg - The generic callback parameter. In this case, this should -/// be a pointer to a Region. +/// be a pointer to a ArrayRef. /// @param Byte - A pointer to the byte to be read. /// @param Address - The address to be read. static int regionReader(const void *Arg, uint8_t *Byte, uint64_t Address) { - auto *R = static_cast(Arg); - ArrayRef Bytes = R->Bytes; - unsigned Index = Address - R->Base; - if (Bytes.size() <= Index) + const ArrayRef *Bytes = static_cast *>(Arg); + if (Bytes->size() <= Address) return -1; - *Byte = Bytes[Index]; + *Byte = Bytes->data()[Address]; return 0; } @@ -147,9 +139,7 @@ if (&VStream == &nulls()) LoggerFn = nullptr; // Disable logging completely if it's going to nulls(). - Region R(Bytes, Address); - - int Ret = decodeInstruction(&InternalInstr, regionReader, (const void *)&R, + int Ret = decodeInstruction(&InternalInstr, regionReader, (const void *)&Bytes, LoggerFn, (void *)&VStream, (const void *)MII.get(), Address, fMode);