From 1dc15b79979019e7abd6c37122970a328d26f585 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 11 Jul 2002 20:30:18 +0000 Subject: [PATCH] * Nodes now keep track of any global variables contained within them git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2877 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/DataStructure.h | 19 +++++++++++++++---- .../Analysis/DataStructure/DataStructure.h | 19 +++++++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/include/llvm/Analysis/DataStructure.h b/include/llvm/Analysis/DataStructure.h index c0240a49257..c417a49ad46 100644 --- a/include/llvm/Analysis/DataStructure.h +++ b/include/llvm/Analysis/DataStructure.h @@ -11,12 +11,12 @@ #include class Type; +class GlobalValue; class DSNode; // Each node in the graph class DSGraph; // A graph for a function class DSNodeIterator; // Data structure graph traversal iterator class LocalDataStructures; // A collection of local graphs for a program - //===----------------------------------------------------------------------===// // DSNodeHandle - Implement a "handle" to a data structure node that takes care // of all of the add/un'refing of the node to prevent the backpointers in the @@ -62,6 +62,9 @@ class DSNode { std::vector Links; std::vector Referrers; + // Globals - The list of global values that are merged into this node. + std::vector Globals; + DSNode(const DSNode &); // DO NOT IMPLEMENT void operator=(const DSNode &); // DO NOT IMPLEMENT public: @@ -108,6 +111,11 @@ public: return Links[i]; } + // addGlobal - Add an entry for a global value to the Globals list. This also + // marks the node with the 'G' flag if it does not already have it. + // + void addGlobal(GlobalValue *GV); + // addEdgeTo - Add an edge from the current node to the specified node. This // can cause merging of nodes in the graph. // @@ -129,10 +137,10 @@ public: void removeReferrer(DSNodeHandle *H); const std::vector &getReferrers() const { return Referrers; } - void print(std::ostream &O, Function *F) const; + void print(std::ostream &O, const DSGraph *G) const; void dump() const; - std::string getCaption(Function *F) const; + std::string getCaption(const DSGraph *G) const; virtual void dropAllReferences() { Links.clear(); @@ -158,7 +166,10 @@ class DSGraph { // FunctionCalls - This vector maintains a single entry for each call // instruction in the current graph. Each call entry contains DSNodeHandles - // that refer to the arguments that are passed into the function call. + // that refer to the arguments that are passed into the function call. The + // first entry in the vector is the scalar that holds the return value for the + // call, the second is the function scalar being invoked, and the rest are + // pointer arguments to the function. // std::vector > FunctionCalls; #if 0 diff --git a/include/llvm/Analysis/DataStructure/DataStructure.h b/include/llvm/Analysis/DataStructure/DataStructure.h index c0240a49257..c417a49ad46 100644 --- a/include/llvm/Analysis/DataStructure/DataStructure.h +++ b/include/llvm/Analysis/DataStructure/DataStructure.h @@ -11,12 +11,12 @@ #include class Type; +class GlobalValue; class DSNode; // Each node in the graph class DSGraph; // A graph for a function class DSNodeIterator; // Data structure graph traversal iterator class LocalDataStructures; // A collection of local graphs for a program - //===----------------------------------------------------------------------===// // DSNodeHandle - Implement a "handle" to a data structure node that takes care // of all of the add/un'refing of the node to prevent the backpointers in the @@ -62,6 +62,9 @@ class DSNode { std::vector Links; std::vector Referrers; + // Globals - The list of global values that are merged into this node. + std::vector Globals; + DSNode(const DSNode &); // DO NOT IMPLEMENT void operator=(const DSNode &); // DO NOT IMPLEMENT public: @@ -108,6 +111,11 @@ public: return Links[i]; } + // addGlobal - Add an entry for a global value to the Globals list. This also + // marks the node with the 'G' flag if it does not already have it. + // + void addGlobal(GlobalValue *GV); + // addEdgeTo - Add an edge from the current node to the specified node. This // can cause merging of nodes in the graph. // @@ -129,10 +137,10 @@ public: void removeReferrer(DSNodeHandle *H); const std::vector &getReferrers() const { return Referrers; } - void print(std::ostream &O, Function *F) const; + void print(std::ostream &O, const DSGraph *G) const; void dump() const; - std::string getCaption(Function *F) const; + std::string getCaption(const DSGraph *G) const; virtual void dropAllReferences() { Links.clear(); @@ -158,7 +166,10 @@ class DSGraph { // FunctionCalls - This vector maintains a single entry for each call // instruction in the current graph. Each call entry contains DSNodeHandles - // that refer to the arguments that are passed into the function call. + // that refer to the arguments that are passed into the function call. The + // first entry in the vector is the scalar that holds the return value for the + // call, the second is the function scalar being invoked, and the rest are + // pointer arguments to the function. // std::vector > FunctionCalls; #if 0