views:

66

answers:

1

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

+2  A: 

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.

Zifre
That's exactly what you need.
Richard Pennington