diff options
author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2017-07-26 23:20:35 +0000 |
---|---|---|
committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2017-07-26 23:20:35 +0000 |
commit | e4fc6ee790009a1486af2ec1c0ee4f55d1ef6a26 (patch) | |
tree | 671c1eb69f6a406a0a30ede46e652989f166f8b6 /llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp | |
parent | 08e38d6b3d89bd04a41c1a0518ef8e7217a72b38 (diff) | |
download | bcm5719-llvm-e4fc6ee790009a1486af2ec1c0ee4f55d1ef6a26.tar.gz bcm5719-llvm-e4fc6ee790009a1486af2ec1c0ee4f55d1ef6a26.zip |
[Hexagon] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 309230
Diffstat (limited to 'llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp')
-rw-r--r-- | llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp b/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp index b5b46f2b7d1..e948e8e86ee 100644 --- a/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp +++ b/llvm/lib/Target/Hexagon/HexagonCommonGEP.cpp @@ -1,4 +1,4 @@ -//===--- HexagonCommonGEP.cpp ---------------------------------------------===// +//===- HexagonCommonGEP.cpp -----------------------------------------------===// // // The LLVM Compiler Infrastructure // @@ -11,6 +11,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/FoldingSet.h" +#include "llvm/ADT/GraphTraits.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Analysis/LoopInfo.h" @@ -27,7 +28,6 @@ #include "llvm/IR/Use.h" #include "llvm/IR/User.h" #include "llvm/IR/Value.h" -#include "llvm/IR/Verifier.h" #include "llvm/Pass.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Casting.h" @@ -66,12 +66,12 @@ namespace llvm { namespace { struct GepNode; - typedef std::set<GepNode*> NodeSet; - typedef std::map<GepNode*,Value*> NodeToValueMap; - typedef std::vector<GepNode*> NodeVect; - typedef std::map<GepNode*,NodeVect> NodeChildrenMap; - typedef std::set<Use*> UseSet; - typedef std::map<GepNode*,UseSet> NodeToUsesMap; + using NodeSet = std::set<GepNode *>; + using NodeToValueMap = std::map<GepNode *, Value *>; + using NodeVect = std::vector<GepNode *>; + using NodeChildrenMap = std::map<GepNode *, NodeVect>; + using UseSet = std::set<Use *>; + using NodeToUsesMap = std::map<GepNode *, UseSet>; // Numbering map for gep nodes. Used to keep track of ordering for // gep nodes. @@ -114,9 +114,9 @@ namespace { } private: - typedef std::map<Value*,GepNode*> ValueToNodeMap; - typedef std::vector<Value*> ValueVect; - typedef std::map<GepNode*,ValueVect> NodeToValuesMap; + using ValueToNodeMap = std::map<Value *, GepNode *>; + using ValueVect = std::vector<Value *>; + using NodeToValuesMap = std::map<GepNode *, ValueVect>; void getBlockTraversalOrder(BasicBlock *Root, ValueVect &Order); bool isHandledGepForm(GetElementPtrInst *GepI); @@ -160,6 +160,7 @@ namespace { } // end anonymous namespace char HexagonCommonGEP::ID = 0; + INITIALIZE_PASS_BEGIN(HexagonCommonGEP, "hcommgep", "Hexagon Common GEP", false, false) INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) @@ -179,15 +180,15 @@ namespace { InBounds = 0x08 }; - uint32_t Flags; + uint32_t Flags = 0; union { GepNode *Parent; Value *BaseVal; }; - Value *Idx; - Type *PTy; // Type of the pointer operand. + Value *Idx = nullptr; + Type *PTy = nullptr; // Type of the pointer operand. - GepNode() : Flags(0), Parent(nullptr), Idx(nullptr), PTy(nullptr) {} + GepNode() : Parent(nullptr) {} GepNode(const GepNode *N) : Flags(N->Flags), Idx(N->Idx), PTy(N->PTy) { if (Flags & Root) BaseVal = N->BaseVal; @@ -267,7 +268,8 @@ namespace { template <typename NodeContainer> void dump_node_container(raw_ostream &OS, const NodeContainer &S) { - typedef typename NodeContainer::const_iterator const_iterator; + using const_iterator = typename NodeContainer::const_iterator; + for (const_iterator I = S.begin(), E = S.end(); I != E; ++I) OS << *I << ' ' << **I << '\n'; } @@ -282,7 +284,8 @@ namespace { raw_ostream &operator<< (raw_ostream &OS, const NodeToUsesMap &M) LLVM_ATTRIBUTE_UNUSED; raw_ostream &operator<< (raw_ostream &OS, const NodeToUsesMap &M){ - typedef NodeToUsesMap::const_iterator const_iterator; + using const_iterator = NodeToUsesMap::const_iterator; + for (const_iterator I = M.begin(), E = M.end(); I != E; ++I) { const UseSet &Us = I->second; OS << I->first << " -> #" << Us.size() << '{'; @@ -300,6 +303,7 @@ namespace { struct in_set { in_set(const NodeSet &S) : NS(S) {} + bool operator() (GepNode *N) const { return NS.find(N) != NS.end(); } @@ -426,7 +430,8 @@ void HexagonCommonGEP::collect() { static void invert_find_roots(const NodeVect &Nodes, NodeChildrenMap &NCM, NodeVect &Roots) { - typedef NodeVect::const_iterator const_iterator; + using const_iterator = NodeVect::const_iterator; + for (const_iterator I = Nodes.begin(), E = Nodes.end(); I != E; ++I) { GepNode *N = *I; if (N->Flags & GepNode::Root) { @@ -458,9 +463,9 @@ static void nodes_for_root(GepNode *Root, NodeChildrenMap &NCM, namespace { - typedef std::set<NodeSet> NodeSymRel; - typedef std::pair<GepNode*,GepNode*> NodePair; - typedef std::set<NodePair> NodePairSet; + using NodeSymRel = std::set<NodeSet>; + using NodePair = std::pair<GepNode *, GepNode *>; + using NodePairSet = std::set<NodePair>; } // end anonymous namespace @@ -529,7 +534,7 @@ void HexagonCommonGEP::common() { // To do this we need to compare all pairs of nodes. To save time, // first, partition the set of all nodes into sets of potentially equal // nodes, and then compare pairs from within each partition. - typedef std::map<unsigned,NodeSet> NodeSetMap; + using NodeSetMap = std::map<unsigned, NodeSet>; NodeSetMap MaybeEq; for (NodeVect::iterator I = Nodes.begin(), E = Nodes.end(); I != E; ++I) { @@ -588,7 +593,7 @@ void HexagonCommonGEP::common() { }); // Create a projection from a NodeSet to the minimal element in it. - typedef std::map<const NodeSet*,GepNode*> ProjMap; + using ProjMap = std::map<const NodeSet *, GepNode *>; ProjMap PM; for (NodeSymRel::iterator I = EqRel.begin(), E = EqRel.end(); I != E; ++I) { const NodeSet &S = *I; @@ -717,7 +722,9 @@ static BasicBlock *nearest_common_dominatee(DominatorTree *DT, T &Blocks) { template <typename T> static BasicBlock::iterator first_use_of_in_block(T &Values, BasicBlock *B) { BasicBlock::iterator FirstUse = B->end(), BEnd = B->end(); - typedef typename T::iterator iterator; + + using iterator = typename T::iterator; + for (iterator I = Values.begin(), E = Values.end(); I != E; ++I) { Value *V = *I; // If V is used in a PHI node, the use belongs to the incoming block, @@ -1247,7 +1254,9 @@ void HexagonCommonGEP::removeDeadCode() { for (unsigned i = BO.size(); i > 0; --i) { BasicBlock *B = cast<BasicBlock>(BO[i-1]); BasicBlock::InstListType &IL = B->getInstList(); - typedef BasicBlock::InstListType::reverse_iterator reverse_iterator; + + using reverse_iterator = BasicBlock::InstListType::reverse_iterator; + ValueVect Ins; for (reverse_iterator I = IL.rbegin(), E = IL.rend(); I != E; ++I) Ins.push_back(&*I); |