Toshiyasu Morita via llvm-dev
2017-Mar-08 23:44 UTC
[llvm-dev] LLVMGetBitcodeModuleInContext2 problem
> > > module_path = LLVMCreateMemoryBufferWithMemoryRange(path, > strlen(path), "path", 1); >LLVMCreateMemoryBufferWithContentsOfFile takes a path. Erm...no...the code is calling LLVMCreateMemoryBufferWithMemoryRange, not LLVMCreateMemoryBufferWithContentsOfFile... Or do you mean I need to load the module into memory before calling LLVMGetBitcodeModuleInContext2? Toshi On Wed, Mar 8, 2017 at 3:40 PM, Friedman, Eli <efriedma at codeaurora.org> wrote:> On 3/8/2017 3:29 PM, Toshiyasu Morita via llvm-dev wrote: > >> >> I'm trying to use LLVMGetBitcodeModuleInContext2 to load a .bc file. >> However, it's not working. >> >> The code looks something like this: >> >> void llvm_load_IR_library(char *path) >> >> { >> LLVMContextRef global_context; >> LLVMMemoryBufferRef module_path; >> LLVMModuleRef ir_lib_module; >> bool flag; >> >> module_path = LLVMCreateMemoryBufferWithMemoryRange(path, >> strlen(path), "path", 1); >> > > LLVMCreateMemoryBufferWithContentsOfFile takes a path. > > -Eli > > -- > Employee of Qualcomm Innovation Center, Inc. > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux > Foundation Collaborative Project > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170308/a53ba2dc/attachment.html>
Friedman, Eli via llvm-dev
2017-Mar-08 23:48 UTC
[llvm-dev] LLVMGetBitcodeModuleInContext2 problem
On 3/8/2017 3:44 PM, Toshiyasu Morita wrote:> > > module_path = LLVMCreateMemoryBufferWithMemoryRange(path, > strlen(path), "path", 1); > > > LLVMCreateMemoryBufferWithContentsOfFile takes a path. > > Erm...no...the code is calling LLVMCreateMemoryBufferWithMemoryRange, > not LLVMCreateMemoryBufferWithContentsOfFile... > > Or do you mean I need to load the module into memory before calling > LLVMGetBitcodeModuleInContext2?Yes, you need to load the module into memory first. LLVMCreateMemoryBufferWithContentsOfFile will do that for you. -Eli -- Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170308/1eaa9d2d/attachment.html>
Toshiyasu Morita via llvm-dev
2017-Mar-08 23:56 UTC
[llvm-dev] LLVMGetBitcodeModuleInContext2 problem
Or do you mean I need to load the module into memory before calling LLVMGetBitcodeModuleInContext2?> Yes, you need to load the module into memory first. > LLVMCreateMemoryBufferWithContentsOfFile will do that for you.Thanks! On Wed, Mar 8, 2017 at 3:48 PM, Friedman, Eli <efriedma at codeaurora.org> wrote:> On 3/8/2017 3:44 PM, Toshiyasu Morita wrote: > > >> module_path = LLVMCreateMemoryBufferWithMemoryRange(path, >> strlen(path), "path", 1); >> > > LLVMCreateMemoryBufferWithContentsOfFile takes a path. > > Erm...no...the code is calling LLVMCreateMemoryBufferWithMemoryRange, not > LLVMCreateMemoryBufferWithContentsOfFile... > > Or do you mean I need to load the module into memory before calling > LLVMGetBitcodeModuleInContext2? > > > Yes, you need to load the module into memory first. > LLVMCreateMemoryBufferWithContentsOfFile will do that for you. > > -Eli > > -- > Employee of Qualcomm Innovation Center, Inc. > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170308/6bc6c384/attachment.html>