From 7fc5b874806127cea6c610297a86d446dbfa6120 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 12 Nov 2014 02:04:27 +0000 Subject: Pass an ArrayRef to MCDisassembler::getInstruction. With this patch MCDisassembler::getInstruction takes an ArrayRef instead of a MemoryObject. Even on X86 there is a maximum size an instruction can have. Given that, it seems way simpler and more efficient to just pass an ArrayRef to the disassembler instead of a MemoryObject and have it do a virtual call every time it wants some extra bytes. llvm-svn: 221751 --- llvm/lib/MC/MCDisassembler/Disassembler.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'llvm/lib/MC/MCDisassembler/Disassembler.cpp') diff --git a/llvm/lib/MC/MCDisassembler/Disassembler.cpp b/llvm/lib/MC/MCDisassembler/Disassembler.cpp index 22095313f1c..bb2d707b404 100644 --- a/llvm/lib/MC/MCDisassembler/Disassembler.cpp +++ b/llvm/lib/MC/MCDisassembler/Disassembler.cpp @@ -245,8 +245,7 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes, size_t OutStringSize){ LLVMDisasmContext *DC = (LLVMDisasmContext *)DCR; // Wrap the pointer to the Bytes, BytesSize and PC in a MemoryObject. - StringRef Data((const char*) Bytes, BytesSize); - StringRefMemoryObject MemoryObject(Data, PC); + ArrayRef Data(Bytes, BytesSize); uint64_t Size; MCInst Inst; @@ -255,7 +254,7 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes, MCDisassembler::DecodeStatus S; SmallVector InsnStr; raw_svector_ostream Annotations(InsnStr); - S = DisAsm->getInstruction(Inst, Size, MemoryObject, PC, + S = DisAsm->getInstruction(Inst, Size, Data, 0, /*REMOVE*/ nulls(), Annotations); switch (S) { case MCDisassembler::Fail: -- cgit v1.2.3