diff options
author | Manman Ren <manman.ren@gmail.com> | 2015-03-13 19:24:30 +0000 |
---|---|---|
committer | Manman Ren <manman.ren@gmail.com> | 2015-03-13 19:24:30 +0000 |
commit | 4a9b0ebe83d199d0aa2bc3c7fe1fd24f1280960e (patch) | |
tree | de2cb487b2df81d871467b210044ac36a201750b /llvm/lib/Bitcode/Reader/BitcodeReader.h | |
parent | c6820ec1c2bdfba3f044b634476cdcafda52e0d0 (diff) | |
download | bcm5719-llvm-4a9b0ebe83d199d0aa2bc3c7fe1fd24f1280960e.tar.gz bcm5719-llvm-4a9b0ebe83d199d0aa2bc3c7fe1fd24f1280960e.zip |
Add a parameter for getLazyBitcodeModule to lazily load Metadata.
We only defer loading metadata inside ParseModule when ShouldLazyLoadMetadata
is true and we have not loaded any Metadata block yet.
This commit implements all-or-nothing loading of Metadata. If there is a
request to load any metadata block, we will load all deferred metadata blocks.
We make sure the deferred metadata blocks are loaded before we materialize any
function or a module.
The default value of the added parameter ShouldLazyLoadMetadata for
getLazyBitcodeModule is false, so the default behavior stays the same.
We only set the parameter to true when creating LTOModule in local contexts.
These can only really be used for parsing symbols, so it's unnecessary to ever
load the metadata blocks.
If we are going to enable lazy-loading of Metadata for other usages of
getLazyBitcodeModule, where deferred metadata blocks need to be loaded, we can
expose BitcodeReader::materializeMetadata to Module, similar to
Module::materialize.
rdar://19804575
llvm-svn: 232198
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.h')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.h b/llvm/lib/Bitcode/Reader/BitcodeReader.h index 9803e78b929..0a69148d84d 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.h +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.h @@ -190,6 +190,11 @@ class BitcodeReader : public GVMaterializer { /// stream. DenseMap<Function*, uint64_t> DeferredFunctionInfo; + /// When Metadata block is initially scanned when parsing the module, we may + /// choose to defer parsing of the metadata. This vector contains info about + /// which Metadata blocks are deferred. + std::vector<uint64_t> DeferredMetadataInfo; + /// These are basic blocks forward-referenced by block addresses. They are /// inserted lazily into functions when they're loaded. The basic block ID is /// its index into the vector. @@ -212,6 +217,9 @@ class BitcodeReader : public GVMaterializer { /// Functions that have block addresses taken. This is usually empty. SmallPtrSet<const Function *, 4> BlockAddressesTaken; + /// True if any Metadata block has been materialized. + bool IsMetadataMaterialized; + public: std::error_code Error(BitcodeError E, const Twine &Message); std::error_code Error(BitcodeError E); @@ -237,7 +245,8 @@ public: /// @brief Main interface to parsing a bitcode buffer. /// @returns true if an error occurred. - std::error_code ParseBitcodeInto(Module *M); + std::error_code ParseBitcodeInto(Module *M, + bool ShouldLazyLoadMetadata = false); /// @brief Cheap mechanism to just extract module triple /// @returns true if an error occurred. @@ -245,6 +254,9 @@ public: static uint64_t decodeSignRotatedValue(uint64_t V); + /// Materialize any deferred Metadata block. + std::error_code materializeMetadata(); + private: std::vector<StructType *> IdentifiedStructTypes; StructType *createIdentifiedStructType(LLVMContext &Context, StringRef Name); @@ -340,7 +352,7 @@ private: /// a corresponding error code. std::error_code parseAlignmentValue(uint64_t Exponent, unsigned &Alignment); std::error_code ParseAttrKind(uint64_t Code, Attribute::AttrKind *Kind); - std::error_code ParseModule(bool Resume); + std::error_code ParseModule(bool Resume, bool ShouldLazyLoadMetadata = false); std::error_code ParseAttributeBlock(); std::error_code ParseAttributeGroupBlock(); std::error_code ParseTypeTable(); @@ -349,6 +361,8 @@ private: std::error_code ParseValueSymbolTable(); std::error_code ParseConstants(); std::error_code RememberAndSkipFunctionBody(); + /// Save the positions of the Metadata blocks and skip parsing the blocks. + std::error_code rememberAndSkipMetadata(); std::error_code ParseFunctionBody(Function *F); std::error_code GlobalCleanup(); std::error_code ResolveGlobalAndAliasInits(); |