From 860660ea5e89a6593b6748a78840427019ab573a Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Fri, 20 Feb 2015 22:05:18 +0000 Subject: [PATCH] [RewriteStatepointsForGC] More style cleanup [NFC] Use llvm_unreachable where appropriate, use SmallVector where easy to do so, introduce typedefs for planned type migrations. llvm-svn: 230068 --- .../Transforms/Scalar/RewriteStatepointsForGC.cpp | 29 +++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index 6e9bc6e..baa49e3 100644 --- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -96,10 +96,11 @@ namespace { // base relation will remain. Internally, we add a mixture of the two // types, then update all the second type to the first type typedef std::map DefiningValueMapTy; +typedef std::set StatepointLiveSetTy; struct PartiallyConstructedSafepointRecord { /// The set of values known to be live accross this safepoint - std::set liveset; + StatepointLiveSetTy liveset; /// Mapping from live pointers to a base-defining-value DenseMap PointerToBase; @@ -283,7 +284,7 @@ analyzeParsePointLiveness(DominatorTree &DT, const CallSite &CS, // Note: This output is used by several of the test cases // The order of elemtns in a set is not stable, put them in a vec and sort // by name - std::vector temp; + SmallVector temp; temp.insert(temp.end(), liveset.begin(), liveset.end()); std::sort(temp.begin(), temp.end(), order_by_name); errs() << "Live Variables:\n"; @@ -583,13 +584,14 @@ private: Value *base; // non null only if status == base }; +typedef std::map ConflictStateMapTy; // Values of type PhiState form a lattice, and this is a helper // class that implementes the meet operation. The meat of the meet // operation is implemented in MeetPhiStates::pureMeet class MeetPhiStates { public: // phiStates is a mapping from PHINodes and SelectInst's to PhiStates. - explicit MeetPhiStates(const std::map &phiStates) + explicit MeetPhiStates(const ConflictStateMapTy &phiStates) : phiStates(phiStates) {} // Destructively meet the current result with the base V. V can @@ -607,7 +609,7 @@ public: PhiState getResult() const { return currentResult; } private: - const std::map &phiStates; + const ConflictStateMapTy &phiStates; PhiState currentResult; /// Return a phi state for a base defining value. We'll generate a new @@ -687,7 +689,7 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache, // analougous to pessimistic data flow and would likely lead to an // overall worse solution. - std::map states; + ConflictStateMapTy states; states[def] = PhiState(); // Recursively fill in all phis & selects reachable from the initial one // for which we don't already know a definite base value for @@ -820,9 +822,8 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache, v->getParent()->getParent()->getParent()->getContext(), MDConst); basesel->setMetadata("is_base_value", md); states[v] = PhiState(PhiState::Conflict, basesel); - } else { - assert(false); - } + } else + llvm_unreachable("unknown conflict type"); } } @@ -922,9 +923,8 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache, } basesel->setOperand(i, base); } - } else { - assert(false && "unexpected type"); - } + } else + llvm_unreachable("unexpected conflict type"); } } @@ -1356,7 +1356,7 @@ static void stablize_order(SmallVectorImpl &basevec, SmallVectorImpl &livevec) { assert(basevec.size() == livevec.size()); - std::vector temp; + SmallVector temp; for (size_t i = 0; i < basevec.size(); i++) { name_ordering v; v.base = basevec[i]; @@ -1654,9 +1654,8 @@ static void insertUseHolderAfter(CallSite &CS, const ArrayRef Values, Func, Values, "", invoke->getUnwindDest()->getFirstInsertionPt()); holders.push_back(normal_holder); holders.push_back(unwind_holder); - } else { - assert(false && "Unsupported"); - } + } else + llvm_unreachable("unsupported call type"); } static void findLiveReferences( -- 2.7.4