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 moduleParseIR
- 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
?
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