diff options
author | Reid Kleckner <rnk@google.com> | 2017-04-24 20:38:30 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2017-04-24 20:38:30 +0000 |
commit | b4a2d18777f9fe5110b572bb25d0d6187be6f0d9 (patch) | |
tree | c59579769e264eefaf44c5d91dbf3f1b1d1e42d6 /llvm/lib/Bitcode/Writer/ValueEnumerator.h | |
parent | b2c390e9f5f71ab8f023a5b428334faac0a07741 (diff) | |
download | bcm5719-llvm-b4a2d18777f9fe5110b572bb25d0d6187be6f0d9.tar.gz bcm5719-llvm-b4a2d18777f9fe5110b572bb25d0d6187be6f0d9.zip |
[Bitcode] Refactor attribute group writing to avoid getSlotAttributes
Summary:
That API creates a temporary AttributeList to carry an index and a
single AttributeSet. We need to carry the index in addition to the set,
because that is how attribute groups are currently encoded.
NFC
Reviewers: pcc
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D32262
llvm-svn: 301245
Diffstat (limited to 'llvm/lib/Bitcode/Writer/ValueEnumerator.h')
-rw-r--r-- | llvm/lib/Bitcode/Writer/ValueEnumerator.h | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/llvm/lib/Bitcode/Writer/ValueEnumerator.h b/llvm/lib/Bitcode/Writer/ValueEnumerator.h index 8a82aab2983..e7ccc8df1e5 100644 --- a/llvm/lib/Bitcode/Writer/ValueEnumerator.h +++ b/llvm/lib/Bitcode/Writer/ValueEnumerator.h @@ -48,6 +48,10 @@ public: // For each value, we remember its Value* and occurrence frequency. typedef std::vector<std::pair<const Value*, unsigned> > ValueList; + /// Attribute groups as encoded in bitcode are almost AttributeSets, but they + /// include the AttributeList index, so we have to track that in our map. + typedef std::pair<unsigned, AttributeSet> IndexAndAttrSet; + UseListOrderStack UseListOrders; private: @@ -102,13 +106,13 @@ private: bool ShouldPreserveUseListOrder; - typedef DenseMap<AttributeList, unsigned> AttributeGroupMapType; + typedef DenseMap<IndexAndAttrSet, unsigned> AttributeGroupMapType; AttributeGroupMapType AttributeGroupMap; - std::vector<AttributeList> AttributeGroups; + std::vector<IndexAndAttrSet> AttributeGroups; - typedef DenseMap<AttributeList, unsigned> AttributeMapType; - AttributeMapType AttributeMap; - std::vector<AttributeList> Attribute; + typedef DenseMap<AttributeList, unsigned> AttributeListMapType; + AttributeListMapType AttributeListMap; + std::vector<AttributeList> AttributeLists; /// GlobalBasicBlockIDs - This map memoizes the basic block ID's referenced by /// the "getGlobalBasicBlockID" method. @@ -166,16 +170,17 @@ public: unsigned getInstructionID(const Instruction *I) const; void setInstructionID(const Instruction *I); - unsigned getAttributeID(AttributeList PAL) const { + unsigned getAttributeListID(AttributeList PAL) const { if (PAL.isEmpty()) return 0; // Null maps to zero. - AttributeMapType::const_iterator I = AttributeMap.find(PAL); - assert(I != AttributeMap.end() && "Attribute not in ValueEnumerator!"); + AttributeListMapType::const_iterator I = AttributeListMap.find(PAL); + assert(I != AttributeListMap.end() && "Attribute not in ValueEnumerator!"); return I->second; } - unsigned getAttributeGroupID(AttributeList PAL) const { - if (PAL.isEmpty()) return 0; // Null maps to zero. - AttributeGroupMapType::const_iterator I = AttributeGroupMap.find(PAL); + unsigned getAttributeGroupID(IndexAndAttrSet Group) const { + if (!Group.second.hasAttributes()) + return 0; // Null maps to zero. + AttributeGroupMapType::const_iterator I = AttributeGroupMap.find(Group); assert(I != AttributeGroupMap.end() && "Attribute not in ValueEnumerator!"); return I->second; } @@ -206,8 +211,8 @@ public: const std::vector<const BasicBlock*> &getBasicBlocks() const { return BasicBlocks; } - const std::vector<AttributeList> &getAttributes() const { return Attribute; } - const std::vector<AttributeList> &getAttributeGroups() const { + const std::vector<AttributeList> &getAttributeLists() const { return AttributeLists; } + const std::vector<IndexAndAttrSet> &getAttributeGroups() const { return AttributeGroups; } |