From: Chris Lattner Date: Wed, 27 Mar 2002 19:41:45 +0000 (+0000) Subject: * Add a nice utility method to DSNode X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=b3ebdadb2c3d7ac7dd36975cd1b1642da39fa81b;p=oota-llvm.git * Add a nice utility method to DSNode * Export interface to tell whether an alloc node represent a malloc or alloca * Add the concept of a "critical" shadow node git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2000 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Analysis/DataStructure.h b/include/llvm/Analysis/DataStructure.h index 55029b26945..73cc19f3f0a 100644 --- a/include/llvm/Analysis/DataStructure.h +++ b/include/llvm/Analysis/DataStructure.h @@ -128,6 +128,10 @@ public: void removeReferrer(PointerValSet *PVS); const std::vector &getReferrers() const { return Referrers; } + // removeAllIncomingEdges - Erase all edges in the graph that point to + // this node + void removeAllIncomingEdges(); + void addPointer(Value *V) { Pointers.push_back(V); } const std::vector &getPointers() const { return Pointers; } @@ -170,6 +174,9 @@ public: virtual std::string getCaption() const; + bool isAllocaNode() const; + bool isMallocNode() const { return !isAllocaNode(); } + // Support type inquiry through isa, cast, and dyn_cast... static bool classof(const NewDSNode *) { return true; } static bool classof(const DSNode *N) { return N->NodeType == NewNode; } @@ -256,14 +263,22 @@ private: // to. When functions are integrated into each other, shadow nodes are // resolved. // +// Shadow nodes may be marked as "critical" nodes when they are created. This +// mark indicates that the node is the result of a function call, the value +// pointed to by an incoming argument, or the value pointed to by a global +// variable [fixme todo]. Since it is not possible to know what these nodes +// point to, given just the current context, they are marked "Critical" to avoid +// having the shadow node merger eliminate them. +// class ShadowDSNode : public DSNode { friend class FunctionDSGraph; DSNode *Parent; Module *Mod; ShadowDSNode *ShadowParent; // Nonnull if this is a synthesized node... std::vector > SynthNodes; + bool CriticalNode; public: - ShadowDSNode(DSNode *Parent, Module *M); + ShadowDSNode(DSNode *Parent, Module *M, bool Critical = false); virtual std::string getCaption() const; // synthesizeNode - Create a new shadow node that is to be linked into this @@ -271,6 +286,9 @@ public: // ShadowDSNode *synthesizeNode(const Type *Ty, FunctionRepBuilder *Rep); + bool isCriticalNode() const { return CriticalNode; } + void resetCriticalMark() { CriticalNode = false; } + // Support type inquiry through isa, cast, and dyn_cast... static bool classof(const ShadowDSNode *) { return true; } static bool classof(const DSNode *N) { return N->NodeType == ShadowNode; } @@ -284,7 +302,7 @@ protected: if (ShadowParent) return new ShadowDSNode(getType(), Mod, ShadowParent); else - return new ShadowDSNode(Parent, Mod); + return new ShadowDSNode(Parent, Mod, CriticalNode); } }; diff --git a/include/llvm/Analysis/DataStructure/DataStructure.h b/include/llvm/Analysis/DataStructure/DataStructure.h index 55029b26945..73cc19f3f0a 100644 --- a/include/llvm/Analysis/DataStructure/DataStructure.h +++ b/include/llvm/Analysis/DataStructure/DataStructure.h @@ -128,6 +128,10 @@ public: void removeReferrer(PointerValSet *PVS); const std::vector &getReferrers() const { return Referrers; } + // removeAllIncomingEdges - Erase all edges in the graph that point to + // this node + void removeAllIncomingEdges(); + void addPointer(Value *V) { Pointers.push_back(V); } const std::vector &getPointers() const { return Pointers; } @@ -170,6 +174,9 @@ public: virtual std::string getCaption() const; + bool isAllocaNode() const; + bool isMallocNode() const { return !isAllocaNode(); } + // Support type inquiry through isa, cast, and dyn_cast... static bool classof(const NewDSNode *) { return true; } static bool classof(const DSNode *N) { return N->NodeType == NewNode; } @@ -256,14 +263,22 @@ private: // to. When functions are integrated into each other, shadow nodes are // resolved. // +// Shadow nodes may be marked as "critical" nodes when they are created. This +// mark indicates that the node is the result of a function call, the value +// pointed to by an incoming argument, or the value pointed to by a global +// variable [fixme todo]. Since it is not possible to know what these nodes +// point to, given just the current context, they are marked "Critical" to avoid +// having the shadow node merger eliminate them. +// class ShadowDSNode : public DSNode { friend class FunctionDSGraph; DSNode *Parent; Module *Mod; ShadowDSNode *ShadowParent; // Nonnull if this is a synthesized node... std::vector > SynthNodes; + bool CriticalNode; public: - ShadowDSNode(DSNode *Parent, Module *M); + ShadowDSNode(DSNode *Parent, Module *M, bool Critical = false); virtual std::string getCaption() const; // synthesizeNode - Create a new shadow node that is to be linked into this @@ -271,6 +286,9 @@ public: // ShadowDSNode *synthesizeNode(const Type *Ty, FunctionRepBuilder *Rep); + bool isCriticalNode() const { return CriticalNode; } + void resetCriticalMark() { CriticalNode = false; } + // Support type inquiry through isa, cast, and dyn_cast... static bool classof(const ShadowDSNode *) { return true; } static bool classof(const DSNode *N) { return N->NodeType == ShadowNode; } @@ -284,7 +302,7 @@ protected: if (ShadowParent) return new ShadowDSNode(getType(), Mod, ShadowParent); else - return new ShadowDSNode(Parent, Mod); + return new ShadowDSNode(Parent, Mod, CriticalNode); } };