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.
| 5854 | /// \param[in] MaterializeAll Set to \c true if we should materialize |
| 5855 | /// everything. |
| 5856 | Expected<std::unique_ptr<Module>> |
| 5857 | BitcodeModule::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 | |
| 5897 | Expected<std::unique_ptr<Module>> |
| 5898 | BitcodeModule::getLazyModule(LLVMContext &Context, bool ShouldLazyLoadMetadata, |
nothing calls this directly
no test coverage detected