[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
This commit is contained in:
Reid Kleckner
2017-04-24 20:38:30 +00:00
parent 49800c056e
commit 5cfbfd6138
5 changed files with 65 additions and 54 deletions
+6 -6
View File
@@ -891,19 +891,19 @@ void ValueEnumerator::EnumerateAttributes(AttributeList PAL) {
if (PAL.isEmpty()) return; // null is always 0.
// Do a lookup.
unsigned &Entry = AttributeMap[PAL];
unsigned &Entry = AttributeListMap[PAL];
if (Entry == 0) {
// Never saw this before, add it.
Attribute.push_back(PAL);
Entry = Attribute.size();
AttributeLists.push_back(PAL);
Entry = AttributeLists.size();
}
// Do lookups for all attribute groups.
for (unsigned i = 0, e = PAL.getNumSlots(); i != e; ++i) {
AttributeList AS = PAL.getSlotAttributes(i);
unsigned &Entry = AttributeGroupMap[AS];
IndexAndAttrSet Pair = {PAL.getSlotIndex(i), PAL.getSlotSet(i)};
unsigned &Entry = AttributeGroupMap[Pair];
if (Entry == 0) {
AttributeGroups.push_back(AS);
AttributeGroups.push_back(Pair);
Entry = AttributeGroups.size();
}
}