From ded64d5d348ce8d8c5aa42cf63f6de9dd84b7e89 Mon Sep 17 00:00:00 2001 From: rdivacky Date: Thu, 5 Nov 2009 17:17:44 +0000 Subject: Update LLVM to r86140. --- lib/Transforms/Scalar/SCCP.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'lib/Transforms/Scalar/SCCP.cpp') diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 05a0eee..509a6db 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -370,13 +370,13 @@ private: /// by properly seeding constants etc. LatticeVal &getValueState(Value *V) { assert(!isa(V->getType()) && "Should use getStructValueState"); - - // TODO: Change to do insert+find in one operation. - DenseMap::iterator I = ValueState.find(V); - if (I != ValueState.end()) - return I->second; // Common case, already in the map. - LatticeVal &LV = ValueState[V]; + std::pair::iterator, bool> I = + ValueState.insert(std::make_pair(V, LatticeVal())); + LatticeVal &LV = I.first->second; + + if (!I.second) + return LV; // Common case, already in the map. if (Constant *C = dyn_cast(V)) { // Undef values remain undefined. @@ -395,15 +395,15 @@ private: assert(isa(V->getType()) && "Should use getValueState"); assert(i < cast(V->getType())->getNumElements() && "Invalid element #"); - - // TODO: Change to do insert+find in one operation. - DenseMap, LatticeVal>::iterator - I = StructValueState.find(std::make_pair(V, i)); - if (I != StructValueState.end()) - return I->second; // Common case, already in the map. - - LatticeVal &LV = StructValueState[std::make_pair(V, i)]; - + + std::pair, LatticeVal>::iterator, + bool> I = StructValueState.insert( + std::make_pair(std::make_pair(V, i), LatticeVal())); + LatticeVal &LV = I.first->second; + + if (!I.second) + return LV; // Common case, already in the map. + if (Constant *C = dyn_cast(V)) { if (isa(C)) ; // Undef values remain undefined. @@ -1280,9 +1280,10 @@ CallOverdefined: } if (const StructType *STy = dyn_cast(AI->getType())) { - for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) - mergeInValue(getStructValueState(AI, i), AI, - getStructValueState(*CAI, i)); + for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) { + LatticeVal CallArg = getStructValueState(*CAI, i); + mergeInValue(getStructValueState(AI, i), AI, CallArg); + } } else { mergeInValue(AI, getValueState(*CAI)); } -- cgit v1.1