diff options
| author | Tim Shen <timshen91@gmail.com> | 2016-08-19 21:20:13 +0000 |
|---|---|---|
| committer | Tim Shen <timshen91@gmail.com> | 2016-08-19 21:20:13 +0000 |
| commit | b5e0f5ac953243829d52aaa0bab65899810b880b (patch) | |
| tree | d20eb83e0345ef7c1da8278f0a3baa0fadef4b98 | |
| parent | e4582d4a2e36a29b8b7bf3d6e2b20c7ce600ece3 (diff) | |
| download | bcm5719-llvm-b5e0f5ac953243829d52aaa0bab65899810b880b.tar.gz bcm5719-llvm-b5e0f5ac953243829d52aaa0bab65899810b880b.zip | |
[GraphTraits] Make nodes_iterator dereference to NodeType*/NodeRef
Currently nodes_iterator may dereference to a NodeType* or a NodeType&. Make them all dereference to NodeType*, which is NodeRef later.
Differential Revision: https://reviews.llvm.org/D23704
Differential Revision: https://reviews.llvm.org/D23705
llvm-svn: 279326
19 files changed, 79 insertions, 128 deletions
diff --git a/clang/include/clang/Analysis/Analyses/Dominators.h b/clang/include/clang/Analysis/Analyses/Dominators.h index c64a3ca2551..df6118dc2e7 100644 --- a/clang/include/clang/Analysis/Analyses/Dominators.h +++ b/clang/include/clang/Analysis/Analyses/Dominators.h @@ -181,14 +181,15 @@ template <> struct GraphTraits< ::clang::DomTreeNode* > { return N->end(); } - typedef df_iterator< ::clang::DomTreeNode* > nodes_iterator; + typedef llvm::pointer_iterator<df_iterator<::clang::DomTreeNode *>> + nodes_iterator; static nodes_iterator nodes_begin(::clang::DomTreeNode *N) { - return df_begin(getEntryNode(N)); + return nodes_iterator(df_begin(getEntryNode(N))); } static nodes_iterator nodes_end(::clang::DomTreeNode *N) { - return df_end(getEntryNode(N)); + return nodes_iterator(df_end(getEntryNode(N))); } }; @@ -199,11 +200,11 @@ template <> struct GraphTraits< ::clang::DominatorTree* > } static nodes_iterator nodes_begin(::clang::DominatorTree *N) { - return df_begin(getEntryNode(N)); + return nodes_iterator(df_begin(getEntryNode(N))); } static nodes_iterator nodes_end(::clang::DominatorTree *N) { - return df_end(getEntryNode(N)); + return nodes_iterator(df_end(getEntryNode(N))); } }; } // end namespace llvm diff --git a/clang/include/clang/Analysis/CFG.h b/clang/include/clang/Analysis/CFG.h index 02fbf37e9f7..29d20089f4f 100644 --- a/clang/include/clang/Analysis/CFG.h +++ b/clang/include/clang/Analysis/CFG.h @@ -761,55 +761,6 @@ public: AddCXXNewAllocator(false), AddCXXDefaultInitExprInCtors(false) {} }; - /// \brief Provides a custom implementation of the iterator class to have the - /// same interface as Function::iterator - iterator returns CFGBlock - /// (not a pointer to CFGBlock). - class graph_iterator { - public: - typedef CFGBlock value_type; - typedef value_type& reference; - typedef value_type* pointer; - typedef BumpVector<CFGBlock*>::iterator ImplTy; - - graph_iterator(const ImplTy &i) : I(i) {} - - bool operator==(const graph_iterator &X) const { return I == X.I; } - bool operator!=(const graph_iterator &X) const { return I != X.I; } - - reference operator*() const { return **I; } - pointer operator->() const { return *I; } - operator CFGBlock* () { return *I; } - - graph_iterator &operator++() { ++I; return *this; } - graph_iterator &operator--() { --I; return *this; } - - private: - ImplTy I; - }; - - class const_graph_iterator { - public: - typedef const CFGBlock value_type; - typedef value_type& reference; - typedef value_type* pointer; - typedef BumpVector<CFGBlock*>::const_iterator ImplTy; - - const_graph_iterator(const ImplTy &i) : I(i) {} - - bool operator==(const const_graph_iterator &X) const { return I == X.I; } - bool operator!=(const const_graph_iterator &X) const { return I != X.I; } - - reference operator*() const { return **I; } - pointer operator->() const { return *I; } - operator CFGBlock* () const { return *I; } - - const_graph_iterator &operator++() { ++I; return *this; } - const_graph_iterator &operator--() { --I; return *this; } - - private: - ImplTy I; - }; - /// buildCFG - Builds a CFG from an AST. static std::unique_ptr<CFG> buildCFG(const Decl *D, Stmt *AST, ASTContext *C, const BuildOptions &BO); @@ -845,14 +796,10 @@ public: const_iterator begin() const { return Blocks.begin(); } const_iterator end() const { return Blocks.end(); } - graph_iterator nodes_begin() { return graph_iterator(Blocks.begin()); } - graph_iterator nodes_end() { return graph_iterator(Blocks.end()); } - const_graph_iterator nodes_begin() const { - return const_graph_iterator(Blocks.begin()); - } - const_graph_iterator nodes_end() const { - return const_graph_iterator(Blocks.end()); - } + iterator nodes_begin() { return iterator(Blocks.begin()); } + iterator nodes_end() { return iterator(Blocks.end()); } + const_iterator nodes_begin() const { return const_iterator(Blocks.begin()); } + const_iterator nodes_end() const { return const_iterator(Blocks.end()); } reverse_iterator rbegin() { return Blocks.rbegin(); } reverse_iterator rend() { return Blocks.rend(); } @@ -1062,7 +1009,7 @@ template <> struct GraphTraits<Inverse<const ::clang::CFGBlock*> > { template <> struct GraphTraits< ::clang::CFG* > : public GraphTraits< ::clang::CFGBlock *> { - typedef ::clang::CFG::graph_iterator nodes_iterator; + typedef ::clang::CFG::iterator nodes_iterator; static NodeType *getEntryNode(::clang::CFG* F) { return &F->getEntry(); } static nodes_iterator nodes_begin(::clang::CFG* F) { return F->nodes_begin();} @@ -1073,7 +1020,7 @@ template <> struct GraphTraits< ::clang::CFG* > template <> struct GraphTraits<const ::clang::CFG* > : public GraphTraits<const ::clang::CFGBlock *> { - typedef ::clang::CFG::const_graph_iterator nodes_iterator; + typedef ::clang::CFG::const_iterator nodes_iterator; static NodeType *getEntryNode( const ::clang::CFG* F) { return &F->getEntry(); @@ -1092,7 +1039,7 @@ template <> struct GraphTraits<const ::clang::CFG* > template <> struct GraphTraits<Inverse< ::clang::CFG*> > : public GraphTraits<Inverse< ::clang::CFGBlock*> > { - typedef ::clang::CFG::graph_iterator nodes_iterator; + typedef ::clang::CFG::iterator nodes_iterator; static NodeType *getEntryNode( ::clang::CFG* F) { return &F->getExit(); } static nodes_iterator nodes_begin( ::clang::CFG* F) {return F->nodes_begin();} @@ -1102,7 +1049,7 @@ template <> struct GraphTraits<Inverse< ::clang::CFG*> > template <> struct GraphTraits<Inverse<const ::clang::CFG*> > : public GraphTraits<Inverse<const ::clang::CFGBlock*> > { - typedef ::clang::CFG::const_graph_iterator nodes_iterator; + typedef ::clang::CFG::const_iterator nodes_iterator; static NodeType *getEntryNode(const ::clang::CFG* F) { return &F->getExit(); } static nodes_iterator nodes_begin(const ::clang::CFG* F) { diff --git a/clang/include/clang/Analysis/CallGraph.h b/clang/include/clang/Analysis/CallGraph.h index 241ecd54d30..303fbcec521 100644 --- a/clang/include/clang/Analysis/CallGraph.h +++ b/clang/include/clang/Analysis/CallGraph.h @@ -205,7 +205,8 @@ template <> struct GraphTraits<clang::CallGraph*> return CGN->getRoot(); // Start at the external node! } typedef std::pair<const clang::Decl*, clang::CallGraphNode*> PairTy; - typedef std::pointer_to_unary_function<PairTy, clang::CallGraphNode&> DerefFun; + typedef std::pointer_to_unary_function<PairTy, clang::CallGraphNode *> + DerefFun; // nodes_iterator/begin/end - Allow iteration over all nodes in the graph typedef mapped_iterator<clang::CallGraph::iterator, DerefFun> nodes_iterator; @@ -215,9 +216,7 @@ template <> struct GraphTraits<clang::CallGraph*> static nodes_iterator nodes_end (clang::CallGraph *CG) { return map_iterator(CG->end(), DerefFun(CGdereference)); } - static clang::CallGraphNode &CGdereference(PairTy P) { - return *(P.second); - } + static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; } static unsigned size(clang::CallGraph *CG) { return CG->size(); @@ -230,7 +229,8 @@ template <> struct GraphTraits<const clang::CallGraph*> : return CGN->getRoot(); } typedef std::pair<const clang::Decl*, clang::CallGraphNode*> PairTy; - typedef std::pointer_to_unary_function<PairTy, clang::CallGraphNode&> DerefFun; + typedef std::pointer_to_unary_function<PairTy, clang::CallGraphNode *> + DerefFun; // nodes_iterator/begin/end - Allow iteration over all nodes in the graph typedef mapped_iterator<clang::CallGraph::const_iterator, DerefFun> nodes_iterator; @@ -241,9 +241,7 @@ template <> struct GraphTraits<const clang::CallGraph*> : static nodes_iterator nodes_end(const clang::CallGraph *CG) { return map_iterator(CG->end(), DerefFun(CGdereference)); } - static clang::CallGraphNode &CGdereference(PairTy P) { - return *(P.second); - } + static clang::CallGraphNode *CGdereference(PairTy P) { return P.second; } static unsigned size(const clang::CallGraph *CG) { return CG->size(); diff --git a/llvm/include/llvm/ADT/GraphTraits.h b/llvm/include/llvm/ADT/GraphTraits.h index b1a4028c147..7ca0134f0e6 100644 --- a/llvm/include/llvm/ADT/GraphTraits.h +++ b/llvm/include/llvm/ADT/GraphTraits.h @@ -34,7 +34,8 @@ struct GraphTraits { // // typedef NodeType - Type of Node in the graph // typedef NodeRef - NodeType * - // typedef ChildIteratorType - Type used to iterate over children in graph + // typedef ChildIteratorType - Type used to iterate over children in graph, + // dereference to a NodeRef // static NodeRef getEntryNode(const GraphType &) // Return the entry node of the graph @@ -45,7 +46,7 @@ struct GraphTraits { // node list for the specified node. // - // typedef ...iterator nodes_iterator; + // typedef ...iterator nodes_iterator; - dereference to a NodeRef // static nodes_iterator nodes_begin(GraphType *G) // static nodes_iterator nodes_end (GraphType *G) // nodes_iterator/begin/end - Allow iteration over all nodes in the graph diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h index 0f0f3314f06..3f4428d1874 100644 --- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h +++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h @@ -1271,7 +1271,7 @@ struct BFIDOTGraphTraitsBase : public DefaultDOTGraphTraits { for (NodeIter I = GTraits::nodes_begin(Graph), E = GTraits::nodes_end(Graph); I != E; ++I) { - NodeRef N = &*I; + NodeRef N = *I; MaxFrequency = std::max(MaxFrequency, Graph->getBlockFreq(N).getFrequency()); } diff --git a/llvm/include/llvm/Analysis/CallGraph.h b/llvm/include/llvm/Analysis/CallGraph.h index 2346ef7c96c..9ea22a2e736 100644 --- a/llvm/include/llvm/Analysis/CallGraph.h +++ b/llvm/include/llvm/Analysis/CallGraph.h @@ -460,7 +460,7 @@ struct GraphTraits<CallGraph *> : public GraphTraits<CallGraphNode *> { } typedef std::pair<const Function *const, std::unique_ptr<CallGraphNode>> PairTy; - typedef std::pointer_to_unary_function<const PairTy &, CallGraphNode &> + typedef std::pointer_to_unary_function<const PairTy &, CallGraphNode *> DerefFun; // nodes_iterator/begin/end - Allow iteration over all nodes in the graph @@ -472,7 +472,7 @@ struct GraphTraits<CallGraph *> : public GraphTraits<CallGraphNode *> { return map_iterator(CG->end(), DerefFun(CGdereference)); } - static CallGraphNode &CGdereference(const PairTy &P) { return *P.second; } + static CallGraphNode *CGdereference(const PairTy &P) { return P.second.get(); } }; template <> @@ -483,7 +483,7 @@ struct GraphTraits<const CallGraph *> : public GraphTraits< } typedef std::pair<const Function *const, std::unique_ptr<CallGraphNode>> PairTy; - typedef std::pointer_to_unary_function<const PairTy &, const CallGraphNode &> + typedef std::pointer_to_unary_function<const PairTy &, const CallGraphNode *> DerefFun; // nodes_iterator/begin/end - Allow iteration over all nodes in the graph @@ -495,8 +495,8 @@ struct GraphTraits<const CallGraph *> : public GraphTraits< return map_iterator(CG->end(), DerefFun(CGdereference)); } - static const CallGraphNode &CGdereference(const PairTy &P) { - return *P.second; + static const CallGraphNode *CGdereference(const PairTy &P) { + return P.second.get(); } }; diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h index 533d659d78b..b34978550f1 100644 --- a/llvm/include/llvm/CodeGen/MachineFunction.h +++ b/llvm/include/llvm/CodeGen/MachineFunction.h @@ -625,9 +625,13 @@ template <> struct GraphTraits<MachineFunction*> : } // nodes_iterator/begin/end - Allow iteration over all nodes in the graph - typedef MachineFunction::iterator nodes_iterator; - static nodes_iterator nodes_begin(MachineFunction *F) { return F->begin(); } - static nodes_iterator nodes_end (MachineFunction *F) { return F->end(); } + typedef pointer_iterator<MachineFunction::iterator> nodes_iterator; + static nodes_iterator nodes_begin(MachineFunction *F) { + return nodes_iterator(F->begin()); + } + static nodes_iterator nodes_end(MachineFunction *F) { + return nodes_iterator(F->end()); + } static unsigned size (MachineFunction *F) { return F->size(); } }; template <> struct GraphTraits<const MachineFunction*> : @@ -637,12 +641,12 @@ template <> struct GraphTraits<const MachineFunction*> : } // nodes_iterator/begin/end - Allow iteration over all nodes in the graph - typedef MachineFunction::const_iterator nodes_iterator; + typedef pointer_iterator<MachineFunction::const_iterator> nodes_iterator; static nodes_iterator nodes_begin(const MachineFunction *F) { - return F->begin(); + return nodes_iterator(F->begin()); } static nodes_iterator nodes_end (const MachineFunction *F) { - return F->end(); + return nodes_iterator(F->end()); } static unsigned size (const MachineFunction *F) { return F->size(); diff --git a/llvm/include/llvm/CodeGen/ScheduleDAG.h b/llvm/include/llvm/CodeGen/ScheduleDAG.h index 03a99c305be..f4e7123d88a 100644 --- a/llvm/include/llvm/CodeGen/ScheduleDAG.h +++ b/llvm/include/llvm/CodeGen/ScheduleDAG.h @@ -692,12 +692,12 @@ namespace llvm { }; template <> struct GraphTraits<ScheduleDAG*> : public GraphTraits<SUnit*> { - typedef std::vector<SUnit>::iterator nodes_iterator; + typedef pointer_iterator<std::vector<SUnit>::iterator> nodes_iterator; static nodes_iterator nodes_begin(ScheduleDAG *G) { - return G->SUnits.begin(); + return nodes_iterator(G->SUnits.begin()); } static nodes_iterator nodes_end(ScheduleDAG *G) { - return G->SUnits.end(); + return nodes_iterator(G->SUnits.end()); } }; diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h index 8a89249e92a..e6d71a7be5c 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAG.h +++ b/llvm/include/llvm/CodeGen/SelectionDAG.h @@ -1416,12 +1416,12 @@ private: }; template <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> { - typedef SelectionDAG::allnodes_iterator nodes_iterator; + typedef pointer_iterator<SelectionDAG::allnodes_iterator> nodes_iterator; static nodes_iterator nodes_begin(SelectionDAG *G) { - return G->allnodes_begin(); + return nodes_iterator(G->allnodes_begin()); } static nodes_iterator nodes_end(SelectionDAG *G) { - return G->allnodes_end(); + return nodes_iterator(G->allnodes_end()); } }; diff --git a/llvm/include/llvm/IR/CFG.h b/llvm/include/llvm/IR/CFG.h index a256b5960bb..6e31cdc9338 100644 --- a/llvm/include/llvm/IR/CFG.h +++ b/llvm/include/llvm/IR/CFG.h @@ -229,9 +229,13 @@ template <> struct GraphTraits<Function*> : public GraphTraits<BasicBlock*> { static NodeType *getEntryNode(Function *F) { return &F->getEntryBlock(); } // nodes_iterator/begin/end - Allow iteration over all nodes in the graph - typedef Function::iterator nodes_iterator; - static nodes_iterator nodes_begin(Function *F) { return F->begin(); } - static nodes_iterator nodes_end (Function *F) { return F->end(); } + typedef pointer_iterator<Function::iterator> nodes_iterator; + static nodes_iterator nodes_begin(Function *F) { + return nodes_iterator(F->begin()); + } + static nodes_iterator nodes_end(Function *F) { + return nodes_iterator(F->end()); + } static size_t size (Function *F) { return F->size(); } }; template <> struct GraphTraits<const Function*> : @@ -239,9 +243,13 @@ template <> struct GraphTraits<const Function*> : static NodeType *getEntryNode(const Function *F) {return &F->getEntryBlock();} // nodes_iterator/begin/end - Allow iteration over all nodes in the graph - typedef Function::const_iterator nodes_iterator; - static nodes_iterator nodes_begin(const Function *F) { return F->begin(); } - static nodes_iterator nodes_end (const Function *F) { return F->end(); } + typedef pointer_iterator<Function::const_iterator> nodes_iterator; + static nodes_iterator nodes_begin(const Function *F) { + return nodes_iterator(F->begin()); + } + static nodes_iterator nodes_end(const Function *F) { + return nodes_iterator(F->end()); + } static size_t size (const Function *F) { return F->size(); } }; diff --git a/llvm/include/llvm/Support/GenericDomTree.h b/llvm/include/llvm/Support/GenericDomTree.h index 6cbcac86b85..07a53438085 100644 --- a/llvm/include/llvm/Support/GenericDomTree.h +++ b/llvm/include/llvm/Support/GenericDomTree.h @@ -750,8 +750,8 @@ public: for (typename TraitsTy::nodes_iterator I = TraitsTy::nodes_begin(&F), E = TraitsTy::nodes_end(&F); I != E; ++I) - if (TraitsTy::child_begin(&*I) == TraitsTy::child_end(&*I)) - addRoot(&*I); + if (TraitsTy::child_begin(*I) == TraitsTy::child_end(*I)) + addRoot(*I); Calculate<FT, Inverse<NodeT *>>(*this, F); } diff --git a/llvm/include/llvm/Support/GraphWriter.h b/llvm/include/llvm/Support/GraphWriter.h index ace4328b409..7555d5b31a8 100644 --- a/llvm/include/llvm/Support/GraphWriter.h +++ b/llvm/include/llvm/Support/GraphWriter.h @@ -145,22 +145,14 @@ public: // Loop over the graph, printing it out... for (node_iterator I = GTraits::nodes_begin(G), E = GTraits::nodes_end(G); I != E; ++I) - if (!isNodeHidden(&*I)) - writeNode(&*I); - } - - bool isNodeHidden(NodeRef const *Node) { - return isNodeHidden(*Node); + if (!isNodeHidden(*I)) + writeNode(*I); } bool isNodeHidden(NodeRef Node) { return DTraits.isNodeHidden(Node); } - void writeNode(NodeRef const *Node) { - writeNode(*Node); - } - void writeNode(NodeRef Node) { std::string NodeAttributes = DTraits.getNodeAttributes(Node, G); diff --git a/llvm/lib/Analysis/BlockFrequencyInfo.cpp b/llvm/lib/Analysis/BlockFrequencyInfo.cpp index 600f945a8b2..a20c8fb280d 100644 --- a/llvm/lib/Analysis/BlockFrequencyInfo.cpp +++ b/llvm/lib/Analysis/BlockFrequencyInfo.cpp @@ -63,7 +63,7 @@ struct GraphTraits<BlockFrequencyInfo *> { typedef const BasicBlock NodeType; typedef const BasicBlock *NodeRef; typedef succ_const_iterator ChildIteratorType; - typedef Function::const_iterator nodes_iterator; + typedef pointer_iterator<Function::const_iterator> nodes_iterator; static inline const NodeType *getEntryNode(const BlockFrequencyInfo *G) { return &G->getFunction()->front(); @@ -75,10 +75,10 @@ struct GraphTraits<BlockFrequencyInfo *> { return succ_end(N); } static nodes_iterator nodes_begin(const BlockFrequencyInfo *G) { - return G->getFunction()->begin(); + return nodes_iterator(G->getFunction()->begin()); } static nodes_iterator nodes_end(const BlockFrequencyInfo *G) { - return G->getFunction()->end(); + return nodes_iterator(G->getFunction()->end()); } }; diff --git a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp b/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp index 22d47fe1443..4147e5e1bb6 100644 --- a/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp +++ b/llvm/lib/CodeGen/MachineBlockFrequencyInfo.cpp @@ -55,7 +55,7 @@ template <> struct GraphTraits<MachineBlockFrequencyInfo *> { typedef const MachineBasicBlock NodeType; typedef const MachineBasicBlock *NodeRef; typedef MachineBasicBlock::const_succ_iterator ChildIteratorType; - typedef MachineFunction::const_iterator nodes_iterator; + typedef pointer_iterator<MachineFunction::const_iterator> nodes_iterator; static inline const NodeType * getEntryNode(const MachineBlockFrequencyInfo *G) { @@ -71,11 +71,11 @@ template <> struct GraphTraits<MachineBlockFrequencyInfo *> { } static nodes_iterator nodes_begin(const MachineBlockFrequencyInfo *G) { - return G->getFunction()->begin(); + return nodes_iterator(G->getFunction()->begin()); } static nodes_iterator nodes_end(const MachineBlockFrequencyInfo *G) { - return G->getFunction()->end(); + return nodes_iterator(G->getFunction()->end()); } }; diff --git a/llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp b/llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp index 5ad80f65ac1..64dcb4558aa 100644 --- a/llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp +++ b/llvm/lib/Target/AMDGPU/AMDILCFGStructurizer.cpp @@ -840,7 +840,7 @@ bool AMDGPUCFGStructurizer::run() { } //while, "one iteration" over the function. MachineBasicBlock *EntryMBB = - &*GraphTraits<MachineFunction *>::nodes_begin(FuncRep); + *GraphTraits<MachineFunction *>::nodes_begin(FuncRep); if (EntryMBB->succ_size() == 0) { Finish = true; DEBUG( @@ -863,7 +863,7 @@ bool AMDGPUCFGStructurizer::run() { } while (!Finish && MakeProgress); // Misc wrap up to maintain the consistency of the Function representation. - wrapup(&*GraphTraits<MachineFunction *>::nodes_begin(FuncRep)); + wrapup(*GraphTraits<MachineFunction *>::nodes_begin(FuncRep)); // Detach retired Block, release memory. for (MBBInfoMap::iterator It = BlockInfoMap.begin(), E = BlockInfoMap.end(); @@ -907,9 +907,9 @@ void AMDGPUCFGStructurizer::orderBlocks(MachineFunction *MF) { //walk through all the block in func to check for unreachable typedef GraphTraits<MachineFunction *> GTM; - MachineFunction::iterator It = GTM::nodes_begin(MF), E = GTM::nodes_end(MF); + auto It = GTM::nodes_begin(MF), E = GTM::nodes_end(MF); for (; It != E; ++It) { - MachineBasicBlock *MBB = &(*It); + MachineBasicBlock *MBB = *It; SccNum = getSCCNum(MBB); if (SccNum == INVALIDSCCNUM) dbgs() << "unreachable block BB" << MBB->getNumber() << "\n"; diff --git a/llvm/lib/Transforms/Scalar/NaryReassociate.cpp b/llvm/lib/Transforms/Scalar/NaryReassociate.cpp index 84ccb507a90..5bde45f1779 100644 --- a/llvm/lib/Transforms/Scalar/NaryReassociate.cpp +++ b/llvm/lib/Transforms/Scalar/NaryReassociate.cpp @@ -211,7 +211,7 @@ bool NaryReassociatePass::doOneIteration(Function &F) { // ensures that all bases of a candidate are in Candidates when we process it. for (auto Node = GraphTraits<DominatorTree *>::nodes_begin(DT); Node != GraphTraits<DominatorTree *>::nodes_end(DT); ++Node) { - BasicBlock *BB = Node->getBlock(); + BasicBlock *BB = (*Node)->getBlock(); for (auto I = BB->begin(); I != BB->end(); ++I) { if (SE->isSCEVable(I->getType()) && isPotentiallyNaryReassociable(&*I)) { const SCEV *OldSCEV = SE->getSCEV(&*I); diff --git a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp index d6ae186698c..e0180fb8a03 100644 --- a/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp +++ b/llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp @@ -1152,7 +1152,7 @@ bool SeparateConstOffsetFromGEP::reuniteExts(Function &F) { DominatingExprs.clear(); for (auto Node = GraphTraits<DominatorTree *>::nodes_begin(DT); Node != GraphTraits<DominatorTree *>::nodes_end(DT); ++Node) { - BasicBlock *BB = Node->getBlock(); + BasicBlock *BB = (*Node)->getBlock(); for (auto I = BB->begin(); I != BB->end(); ) { Instruction *Cur = &*I++; Changed |= reuniteExts(Cur); diff --git a/llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp index 292d0400a51..a4da5fe2335 100644 --- a/llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp +++ b/llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp @@ -676,7 +676,7 @@ bool StraightLineStrengthReduce::runOnFunction(Function &F) { // all bases of a candidate are in Candidates when we process it. for (auto node = GraphTraits<DominatorTree *>::nodes_begin(DT); node != GraphTraits<DominatorTree *>::nodes_end(DT); ++node) { - for (auto &I : *node->getBlock()) + for (auto &I : *(*node)->getBlock()) allocateCandidatesAndFindBasis(&I); } diff --git a/llvm/unittests/Analysis/CallGraphTest.cpp b/llvm/unittests/Analysis/CallGraphTest.cpp index af46291074c..0c9280446bc 100644 --- a/llvm/unittests/Analysis/CallGraphTest.cpp +++ b/llvm/unittests/Analysis/CallGraphTest.cpp @@ -24,11 +24,11 @@ template <typename Ty> void canSpecializeGraphTraitsIterators(Ty *G) { auto X = ++I; // Should be able to iterate over all nodes of the graph. - static_assert(std::is_same<decltype(*I), NodeTy &>::value, + static_assert(std::is_same<decltype(*I), NodeTy *>::value, "Node type does not match"); - static_assert(std::is_same<decltype(*X), NodeTy &>::value, + static_assert(std::is_same<decltype(*X), NodeTy *>::value, "Node type does not match"); - static_assert(std::is_same<decltype(*E), NodeTy &>::value, + static_assert(std::is_same<decltype(*E), NodeTy *>::value, "Node type does not match"); NodeTy *N = GraphTraits<Ty *>::getEntryNode(G); |

