diff options
author | Matt Beaumont-Gay <matthewbg@google.com> | 2012-12-14 17:55:15 +0000 |
---|---|---|
committer | Matt Beaumont-Gay <matthewbg@google.com> | 2012-12-14 17:55:15 +0000 |
commit | 6aed25d93d1cfcde5809a73ffa7dc1b0d6396f66 (patch) | |
tree | 57e2fdf1caf960d8d878e0289f32af6759832b49 /lib/Bitcode/Writer/ValueEnumerator.cpp | |
parent | 7139cfb19b1cc28dfd5e274c07ec68835bc6d6d6 (diff) | |
parent | 1ad9253c9d34ccbce3e7e4ea5d87c266cbf93410 (diff) |
Updating branches/google/stable to r169803
git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/google/stable@170212 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Writer/ValueEnumerator.cpp')
-rw-r--r-- | lib/Bitcode/Writer/ValueEnumerator.cpp | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/lib/Bitcode/Writer/ValueEnumerator.cpp b/lib/Bitcode/Writer/ValueEnumerator.cpp index 1ed9004eb5..3c2cce0a16 100644 --- a/lib/Bitcode/Writer/ValueEnumerator.cpp +++ b/lib/Bitcode/Writer/ValueEnumerator.cpp @@ -12,20 +12,20 @@ //===----------------------------------------------------------------------===// #include "ValueEnumerator.h" -#include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/SmallPtrSet.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" -#include "llvm/Module.h" -#include "llvm/ValueSymbolTable.h" #include "llvm/Instructions.h" +#include "llvm/Module.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/ValueSymbolTable.h" #include <algorithm> using namespace llvm; -static bool isIntegerValue(const std::pair<const Value*, unsigned> &V) { - return V.first->getType()->isIntegerTy(); +static bool isIntOrIntVectorValue(const std::pair<const Value*, unsigned> &V) { + return V.first->getType()->isIntOrIntVectorTy(); } /// ValueEnumerator - Enumerate module-level information. @@ -95,7 +95,7 @@ ValueEnumerator::ValueEnumerator(const Module *M) { I->getAllMetadataOtherThanDebugLoc(MDs); for (unsigned i = 0, e = MDs.size(); i != e; ++i) EnumerateMetadata(MDs[i].second); - + if (!I->getDebugLoc().isUnknown()) { MDNode *Scope, *IA; I->getDebugLoc().getScopeAndInlinedAt(Scope, IA, I->getContext()); @@ -192,10 +192,11 @@ void ValueEnumerator::OptimizeConstants(unsigned CstStart, unsigned CstEnd) { CstSortPredicate P(*this); std::stable_sort(Values.begin()+CstStart, Values.begin()+CstEnd, P); - // Ensure that integer constants are at the start of the constant pool. This - // is important so that GEP structure indices come before gep constant exprs. + // Ensure that integer and vector of integer constants are at the start of the + // constant pool. This is important so that GEP structure indices come before + // gep constant exprs. std::partition(Values.begin()+CstStart, Values.begin()+CstEnd, - isIntegerValue); + isIntOrIntVectorValue); // Rebuild the modified portion of ValueMap. for (; CstStart != CstEnd; ++CstStart) @@ -362,16 +363,16 @@ void ValueEnumerator::EnumerateType(Type *Ty) { if (StructType *STy = dyn_cast<StructType>(Ty)) if (!STy->isLiteral()) *TypeID = ~0U; - + // Enumerate all of the subtypes before we enumerate this type. This ensures // that the type will be enumerated in an order that can be directly built. for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); I != E; ++I) EnumerateType(*I); - + // Refresh the TypeID pointer in case the table rehashed. TypeID = &TypeMap[Ty]; - + // Check to see if we got the pointer another way. This can happen when // enumerating recursive types that hit the base case deeper than they start. // @@ -379,10 +380,10 @@ void ValueEnumerator::EnumerateType(Type *Ty) { // then emit the definition now that all of its contents are available. if (*TypeID && *TypeID != ~0U) return; - + // Add this type now that its contents are all happily enumerated. Types.push_back(Ty); - + *TypeID = Types.size(); } @@ -390,7 +391,7 @@ void ValueEnumerator::EnumerateType(Type *Ty) { // walk through it, enumerating the types of the constant. void ValueEnumerator::EnumerateOperandType(const Value *V) { EnumerateType(V->getType()); - + if (const Constant *C = dyn_cast<Constant>(V)) { // If this constant is already enumerated, ignore it, we know its type must // be enumerated. @@ -400,11 +401,11 @@ void ValueEnumerator::EnumerateOperandType(const Value *V) { // them. for (unsigned i = 0, e = C->getNumOperands(); i != e; ++i) { const Value *Op = C->getOperand(i); - + // Don't enumerate basic blocks here, this happens as operands to // blockaddress. if (isa<BasicBlock>(Op)) continue; - + EnumerateOperandType(Op); } @@ -417,7 +418,7 @@ void ValueEnumerator::EnumerateOperandType(const Value *V) { EnumerateMetadata(V); } -void ValueEnumerator::EnumerateAttributes(const AttrListPtr &PAL) { +void ValueEnumerator::EnumerateAttributes(const AttributeSet &PAL) { if (PAL.isEmpty()) return; // null is always 0. // Do a lookup. unsigned &Entry = AttributeMap[PAL.getRawPointer()]; @@ -481,7 +482,7 @@ void ValueEnumerator::incorporateFunction(const Function &F) { if (N->isFunctionLocal() && N->getFunction()) FnLocalMDVector.push_back(N); } - + if (!I->getType()->isVoidTy()) EnumerateValue(I); } |