- // Get the module provider
- MemoryBuffer *Buffer =MemoryBuffer::getNewMemBuffer(Length, ModuleID.c_str());
- memcpy((char*)Buffer->getBufferStart(), BufPtr, Length);
-
- ModuleProvider *MP = getBitcodeModuleProvider(Buffer, ErrMsg);
- if (!MP)
- return 0;
-
- // Get the module from the provider
- Module* M = MP->materializeModule();
- if (M == 0) {
- delete MP;
+ // Get the module.
+ OwningPtr<MemoryBuffer> Buffer(
+ MemoryBuffer::getMemBufferCopy(StringRef(BufPtr, Length),ModuleID.c_str()));
+
+ Module *M = ParseBitcodeFile(Buffer.get(), Context, ErrMsg);
+ if (!M)