diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-11-12 02:04:27 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-11-12 02:04:27 +0000 |
commit | 7fc5b874806127cea6c610297a86d446dbfa6120 (patch) | |
tree | 7ab49f51a0ca5d14fefddd0f6060eec226943a53 /llvm/lib/MC/MCDisassembler/Disassembler.cpp | |
parent | 2e32155b58aecf4ff9643b3bcae7a7f86d228b0a (diff) | |
download | bcm5719-llvm-7fc5b874806127cea6c610297a86d446dbfa6120.tar.gz bcm5719-llvm-7fc5b874806127cea6c610297a86d446dbfa6120.zip |
Pass an ArrayRef to MCDisassembler::getInstruction.
With this patch MCDisassembler::getInstruction takes an ArrayRef<uint8_t>
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
Diffstat (limited to 'llvm/lib/MC/MCDisassembler/Disassembler.cpp')
-rw-r--r-- | llvm/lib/MC/MCDisassembler/Disassembler.cpp | 5 |
1 files changed, 2 insertions, 3 deletions
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<uint8_t> Data(Bytes, BytesSize); uint64_t Size; MCInst Inst; @@ -255,7 +254,7 @@ size_t LLVMDisasmInstruction(LLVMDisasmContextRef DCR, uint8_t *Bytes, MCDisassembler::DecodeStatus S; SmallVector<char, 64> 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: |