diff options
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.h')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.h | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.h b/llvm/lib/Bitcode/Reader/BitcodeReader.h index 10f870b59b8..639ddb90350 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.h +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.h @@ -19,7 +19,9 @@ #include "llvm/Bitcode/LLVMBitCodes.h" #include "llvm/IR/Attributes.h" #include "llvm/IR/GVMaterializer.h" +#include "llvm/IR/Metadata.h" #include "llvm/IR/OperandTraits.h" +#include "llvm/IR/TrackingMDRef.h" #include "llvm/IR/Type.h" #include "llvm/IR/ValueHandle.h" #include <deque> @@ -95,22 +97,25 @@ public: //===----------------------------------------------------------------------===// class BitcodeReaderMDValueList { - std::vector<WeakVH> MDValuePtrs; + unsigned NumFwdRefs; + bool AnyFwdRefs; + std::vector<TrackingMDRef> MDValuePtrs; LLVMContext &Context; public: - BitcodeReaderMDValueList(LLVMContext& C) : Context(C) {} + BitcodeReaderMDValueList(LLVMContext &C) + : NumFwdRefs(0), AnyFwdRefs(false), Context(C) {} // vector compatibility methods unsigned size() const { return MDValuePtrs.size(); } void resize(unsigned N) { MDValuePtrs.resize(N); } - void push_back(Value *V) { MDValuePtrs.push_back(V); } + void push_back(Metadata *MD) { MDValuePtrs.emplace_back(MD); } void clear() { MDValuePtrs.clear(); } - Value *back() const { return MDValuePtrs.back(); } + Metadata *back() const { return MDValuePtrs.back(); } void pop_back() { MDValuePtrs.pop_back(); } bool empty() const { return MDValuePtrs.empty(); } - Value *operator[](unsigned i) const { + Metadata *operator[](unsigned i) const { assert(i < MDValuePtrs.size()); return MDValuePtrs[i]; } @@ -120,8 +125,9 @@ public: MDValuePtrs.resize(N); } - Value *getValueFwdRef(unsigned Idx); - void AssignValue(Value *V, unsigned Idx); + Metadata *getValueFwdRef(unsigned Idx); + void AssignValue(Metadata *MD, unsigned Idx); + void tryToResolveCycles(); }; class BitcodeReader : public GVMaterializer { @@ -248,9 +254,12 @@ private: Type *getTypeByID(unsigned ID); Value *getFnValueByID(unsigned ID, Type *Ty) { if (Ty && Ty->isMetadataTy()) - return MDValueList.getValueFwdRef(ID); + return MetadataAsValue::get(Ty->getContext(), getFnMetadataByID(ID)); return ValueList.getValueFwdRef(ID, Ty); } + Metadata *getFnMetadataByID(unsigned ID) { + return MDValueList.getValueFwdRef(ID); + } BasicBlock *getBasicBlock(unsigned ID) const { if (ID >= FunctionBBs.size()) return nullptr; // Invalid ID return FunctionBBs[ID]; |