Convert std::string to llvm::MemoryBuffer

僤鯓⒐⒋嵵緔 提交于 2019-12-06 10:47:01

问题


I am looking to create an LLVM Module from existing LLVM IR code.

The two methods I have found are the following:

  • ParseIRFile - This accepts a file name and generates a module
  • ParseIR - This accepts MemoryBuffer and generates a module

I want to create a Module when the LLVM IR is already read to a string as an std::string or const char *.

Is there a way to convert an IR string to llvm::MemoryBuffer ?


回答1:


I figured this out with the help of a colleague.

This is how you would do it:

std::string IRString = readfile("add.ll");
MemoryBuffer *mem = MemoryBuffer::getMemBuffer(IRString);


来源:https://stackoverflow.com/questions/25273509/convert-stdstring-to-llvmmemorybuffer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!