MCPcopy Create free account
hub / github.com/GANGE666/xVMP / getModuleImpl

Method getModuleImpl

src/lib/Bitcode/Reader/BitcodeReader.cpp:5856–5895  ·  view source on GitHub ↗

Get a lazy one-at-time loading module from bitcode. This isn't always used in a lazy context. In particular, it's also used by \a parseModule(). If this is truly lazy, then we need to eagerly pull in forward-referenced functions from block address references. \param[in] MaterializeAll Set to \c true if we should materialize everything.

Source from the content-addressed store, hash-verified

5854/// \param[in] MaterializeAll Set to \c true if we should materialize
5855/// everything.
5856Expected<std::unique_ptr<Module>>
5857BitcodeModule::getModuleImpl(LLVMContext &Context, bool MaterializeAll,
5858 bool ShouldLazyLoadMetadata, bool IsImporting) {
5859 BitstreamCursor Stream(Buffer);
5860
5861 std::string ProducerIdentification;
5862 if (IdentificationBit != -1ull) {
5863 Stream.JumpToBit(IdentificationBit);
5864 Expected<std::string> ProducerIdentificationOrErr =
5865 readIdentificationBlock(Stream);
5866 if (!ProducerIdentificationOrErr)
5867 return ProducerIdentificationOrErr.takeError();
5868
5869 ProducerIdentification = *ProducerIdentificationOrErr;
5870 }
5871
5872 Stream.JumpToBit(ModuleBit);
5873 auto *R = new BitcodeReader(std::move(Stream), Strtab, ProducerIdentification,
5874 Context);
5875
5876 std::unique_ptr<Module> M =
5877 llvm::make_unique<Module>(ModuleIdentifier, Context);
5878 M->setMaterializer(R);
5879
5880 // Delay parsing Metadata if ShouldLazyLoadMetadata is true.
5881 if (Error Err =
5882 R->parseBitcodeInto(M.get(), ShouldLazyLoadMetadata, IsImporting))
5883 return std::move(Err);
5884
5885 if (MaterializeAll) {
5886 // Read in the entire module, and destroy the BitcodeReader.
5887 if (Error Err = M->materializeAll())
5888 return std::move(Err);
5889 } else {
5890 // Resolve forward references from blockaddresses.
5891 if (Error Err = R->materializeForwardReferencedFunctions())
5892 return std::move(Err);
5893 }
5894 return std::move(M);
5895}
5896
5897Expected<std::unique_ptr<Module>>
5898BitcodeModule::getLazyModule(LLVMContext &Context, bool ShouldLazyLoadMetadata,

Callers

nothing calls this directly

Calls 9

readIdentificationBlockFunction · 0.85
JumpToBitMethod · 0.80
setMaterializerMethod · 0.80
parseBitcodeIntoMethod · 0.80
materializeAllMethod · 0.80
moveFunction · 0.50
takeErrorMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected