search for: getmembuffercopy

Displaying 9 results from an estimated 9 matches for "getmembuffercopy".

2014 Sep 18
2
[LLVMdev] How to cache MCJIT compiled object into memory?
Hi, All I m not sure if this question has been asked or not. I'd like cache the MCJIT compiled object into memory buffer so it can be reused later. I followed the Andy Kaylor's example wrote an inherited class from ObjectCache and use raw_fd_ostream to save the cache and load the cache from a file. I checked raw_ostream and its subclass, maybe I am wrong but I don't see one is fit to
2014 Mar 19
2
[LLVMdev] load bytecode from string for jiting problem
all of: ---- // cout << "lsr: " << lsr << "\n"; llvm::MemoryBuffer* mbjit = llvm::MemoryBuffer::getMemBufferCopy (sr); ------ string lsr = sr.str(); // cout << "lsr: " << lsr << "\n"; llvm::MemoryBuffer* mbjit = llvm::MemoryBuffer::getMemBuffer (lsr); ------- string lsr...
2014 Mar 20
2
[LLVMdev] load bytecode from string for jiting problem
...)[2] == (char) 0xc0) std::cout << "0xc0 ok\n"; if (sr.str()[3] == (char) 0xde) std::cout << "0xde ok\n"; llvm::MemoryBuffer* mbjit = llvm::MemoryBuffer::getMemBufferCopy (sr); llvm::ErrorOr<llvm::Module*> ModuleOrErr = llvm::parseBitcodeFile (mbjit, context); if (llvm::error_code EC = ModuleOrErr.getError()) { std::cout << ModuleOrErr.getError().message() << "\n"; } Module* Mjit = ModuleOrErr.get(); std::string eeError; Execut...
2016 Jul 07
2
ObjectCache and getFunctionAddress issue
...td::string, std::unique_ptr<llvm::MemoryBuffer>> CachedObjs; public: virtual void notifyObjectCompiled(const llvm::Module *M, llvm::MemoryBufferRef Obj) { auto id = M->getModuleIdentifier(); auto iter = CachedObjs.find(id); if (iter == CachedObjs.end()) { auto buf = llvm::MemoryBuffer::getMemBufferCopy(Obj.getBuffer(), Obj.getBufferIdentifier()); CachedObjs.insert(std::make_pair(id, std::move(buf))); } }; virtual std::unique_ptr<llvm::MemoryBuffer> getObject(const llvm::Module *M) { auto id = M->getModuleIdentifier(); auto iter = CachedObjs.find(id); if (iter != CachedObjs.end()) { llvm:...
2014 Mar 20
2
[LLVMdev] load bytecode from string for jiting problem
...std::cout << "0xc0 ok\n"; >> if (sr.str()[3] == (char) 0xde) >> std::cout << "0xde ok\n"; >> llvm::MemoryBuffer* mbjit = llvm::MemoryBuffer::getMemBufferCopy (sr); >> >> llvm::ErrorOr<llvm::Module*> ModuleOrErr = llvm::parseBitcodeFile >> (mbjit, context); >> if (llvm::error_code EC = ModuleOrErr.getError()) { >> std::cout << ModuleOrErr.getError().message() << "\n"; >> } >> >>...
2014 Mar 19
2
[LLVMdev] load bytecode from string for jiting problem
...quot;sr.str()" ends its lifetime in this > statement, and MemoryBuffer for efficiency reasons > avoids copying data it doesn't have to (like StringRef) so will be > referencing the freed memory. > > To resolve this: > * Pass MemoryBuffer your StringRef directly > * Use getMemBufferCopy() > * Preserve the result of sr.str() into a stack variable and pass that > to getMemoryBuffer() instead. > > As a final note, check if your bitcode buffer "string" is > null-terminated or not. If not, be sure to be careful and > do things like informing MemoryBuffer th...
2014 Mar 13
2
[LLVMdev] load bytecode from string for jiting problem
Hello, I having a weird problem while writing a bytecode module to a string, and after read/parse it for unsing on a jit. I write a pass to export function to module, and put this module inside a global variable. I use WriteBitcodeToFile for this. For debuging, after this write, I try to load the exported module with parseBitcodeFile. This two step works. After, while the compiled program is
2010 May 29
1
[LLVMdev] SVN version fails to compile
...builds ok. Yuri --- errors --- llvm[3]: Compiling gtest-port.cc for Debug build /tmp/llvm-svn/llvm-objects/utils/FileCheck/Debug/FileCheck.o(.text+0x16b5): In function `CanonicalizeInputFile': /tmp/llvm-svn/llvm/utils/FileCheck/FileCheck.cpp:464: undefined reference to `llvm::MemoryBuffer::getMemBufferCopy(llvm::StringRef, char const*)' /tmp/llvm-svn/llvm-objects/utils/FileCheck/Debug/FileCheck.o(.text+0x1767): In function `ReadCheckFile': /tmp/llvm-svn/llvm/utils/FileCheck/FileCheck.cpp:478: undefined reference to `llvm::MemoryBuffer::getFileOrSTDIN(llvm::StringRef, std::basic_string<...
2009 Sep 24
7
[LLVMdev] MemoryBuffer
...rt could access invalid memory if it was to one past the end, but if it was to the end of input and not one past the end that that seems inconsistent, so I am curious as to which it is? I know the comments in the header indicate that the end needs to be dereferencable for getMemBuffer, but not for getMemBufferCopy and other ones, so I am curious as to why it is inconsistent? I do not see any real reason why getMemBuffer has the requirement that the EndPtr needs to be dereferencable except for that assert, and I do not really see a reason for that assert right off the bat. Basically, is there a rational sec...