[llvm] r174844 - Add support for attribute groups in the value enumerator.
Bill Wendling
isanbard at gmail.com
Sun Feb 10 15:06:02 PST 2013
Author: void
Date: Sun Feb 10 17:06:02 2013
New Revision: 174844
URL: http://llvm.org/viewvc/llvm-project?rev=174844&view=rev
Log:
Add support for attribute groups in the value enumerator.
Attribute groups are essentially all AttributeSets which are used by the
program. Enumerate them here.
Modified:
llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h
Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=174844&r1=174843&r2=174844&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Sun Feb 10 17:06:02 2013
@@ -427,6 +427,16 @@ void ValueEnumerator::EnumerateAttribute
Attribute.push_back(PAL);
Entry = Attribute.size();
}
+
+ // Do lookups for all attribute groups.
+ for (unsigned i = 0, e = PAL.getNumSlots(); i != e; ++i) {
+ AttributeSet AS = PAL.getSlotAttributes(i);
+ unsigned &Entry = AttributeSetMap[AS];
+ if (Entry == 0) {
+ AttributeSets.push_back(AS);
+ Entry = AttributeSets.size();
+ }
+ }
}
void ValueEnumerator::incorporateFunction(const Function &F) {
Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h?rev=174844&r1=174843&r2=174844&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h (original)
+++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.h Sun Feb 10 17:06:02 2013
@@ -52,6 +52,10 @@ private:
SmallVector<const MDNode *, 8> FunctionLocalMDs;
ValueMapType MDValueMap;
+ typedef DenseMap<AttributeSet, unsigned> AttributeSetMapType;
+ AttributeSetMapType AttributeSetMap;
+ std::vector<AttributeSet> AttributeSets;
+
typedef DenseMap<void*, unsigned> AttributeMapType;
AttributeMapType AttributeMap;
std::vector<AttributeSet> Attribute;
@@ -105,6 +109,13 @@ public:
return I->second;
}
+ unsigned getAttributeSetID(const AttributeSet &PAL) const {
+ if (PAL.isEmpty()) return 0; // Null maps to zero.
+ AttributeSetMapType::const_iterator I = AttributeSetMap.find(PAL);
+ assert(I != AttributeSetMap.end() && "Attribute not in ValueEnumerator!");
+ return I->second;
+ }
+
/// getFunctionConstantRange - Return the range of values that corresponds to
/// function-local constants.
void getFunctionConstantRange(unsigned &Start, unsigned &End) const {
@@ -124,6 +135,9 @@ public:
const std::vector<AttributeSet> &getAttributes() const {
return Attribute;
}
+ const std::vector<AttributeSet> &getAttributeSets() const {
+ return AttributeSets;
+ }
/// getGlobalBasicBlockID - This returns the function-specific ID for the
/// specified basic block. This is relatively expensive information, so it
More information about the llvm-commits
mailing list