diff --git a/include/llvm/Analysis/DSGraph.h b/include/llvm/Analysis/DSGraph.h index 0126e2d44f8..c5e9396a16b 100644 --- a/include/llvm/Analysis/DSGraph.h +++ b/include/llvm/Analysis/DSGraph.h @@ -53,7 +53,10 @@ public: ~DSGraph(); bool hasFunction() const { return Func != 0; } - Function &getFunction() const { return *Func; } + Function &getFunction() const { + assert(hasFunction() && "Cannot call getFunction on graph without a fn!"); + return *Func; + } DSGraph *getGlobalsGraph() const { return GlobalsGraph; } void setGlobalsGraph(DSGraph *G) { GlobalsGraph = G; } diff --git a/include/llvm/Analysis/DataStructure/DSGraph.h b/include/llvm/Analysis/DataStructure/DSGraph.h index 0126e2d44f8..c5e9396a16b 100644 --- a/include/llvm/Analysis/DataStructure/DSGraph.h +++ b/include/llvm/Analysis/DataStructure/DSGraph.h @@ -53,7 +53,10 @@ public: ~DSGraph(); bool hasFunction() const { return Func != 0; } - Function &getFunction() const { return *Func; } + Function &getFunction() const { + assert(hasFunction() && "Cannot call getFunction on graph without a fn!"); + return *Func; + } DSGraph *getGlobalsGraph() const { return GlobalsGraph; } void setGlobalsGraph(DSGraph *G) { GlobalsGraph = G; } diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index 80c64d126c6..badc9c08013 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -1029,6 +1029,7 @@ void DSGraph::removeDeadNodes(unsigned Flags) { if (AuxFCallsAlive[i]) AuxFunctionCalls[CurIdx++].swap(AuxFunctionCalls[i]); if (!(Flags & DSGraph::RemoveUnreachableGlobals)) { + assert(GlobalsGraph && "No globals graph available??"); // Move the unreachable call nodes to the globals graph... GlobalsGraph->AuxFunctionCalls.insert(GlobalsGraph->AuxFunctionCalls.end(), AuxFunctionCalls.begin()+CurIdx,