开发者

Is it possible to read an LLVM bitcode file into an llvm::Module?

开发者 https://www.devze.com 2023-01-14 14:03 出处:网络
I\'m writing a compiler with LLVM. Each source file is compiled into an LLVM bitcode file. Eventually the linker links and optimizes all the bitcode files into one final binary.

I'm writing a compiler with LLVM. Each source file is compiled into an LLVM bitcode file. Eventually the linker links and optimizes all the bitcode files into one final binary.

I need a way to read the bitcode files in the compiler in order to access the type information. The LLVM documentation shows a c开发者_如何学Golass called BitcodeReader, but that appears to be internal to LLVM.

Is there any publicly accessible way to read a bitcode file into an llvm::Module?


I looked through the source to the llvm-dis tool and found the function I was looking for:

Module *ParseBitcodeFile(MemoryBuffer *Buffer, LLVMContext& Context,
                         std::string *ErrMsg = 0);

from llvm/Bitcode/ReaderWriter.h.

0

精彩评论

暂无评论...
验证码 换一张
取 消