* 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
This commit is contained in:
Chris Lattner 2002-03-27 19:41:45 +00:00
parent 9d42a1d2f9
commit b3ebdadb2c
2 changed files with 40 additions and 4 deletions

View File

@ -128,6 +128,10 @@ public:
void removeReferrer(PointerValSet *PVS);
const std::vector<PointerValSet*> &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<Value*> &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<std::pair<const Type *, ShadowDSNode *> > 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);
}
};

View File

@ -128,6 +128,10 @@ public:
void removeReferrer(PointerValSet *PVS);
const std::vector<PointerValSet*> &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<Value*> &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<std::pair<const Type *, ShadowDSNode *> > 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);
}
};