Make data structure acurately get ALL edges, even loads of null fields of

nodes that are not shadow nodes


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2273 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2002-04-17 03:24:47 +00:00
parent 4a94a70250
commit a146183c21
2 changed files with 24 additions and 20 deletions

View File

@@ -20,6 +20,7 @@ class GlobalValue;
class FunctionDSGraph; class FunctionDSGraph;
class DataStructure; class DataStructure;
class DSNodeIterator; class DSNodeIterator;
class ShadowDSNode;
// FIXME: move this somewhere private // FIXME: move this somewhere private
unsigned countPointerFields(const Type *Ty); unsigned countPointerFields(const Type *Ty);
@@ -114,6 +115,8 @@ class DSNode {
std::vector<Value*> Pointers; // Values pointing to me... std::vector<Value*> Pointers; // Values pointing to me...
std::vector<PointerValSet*> Referrers; std::vector<PointerValSet*> Referrers;
std::vector<std::pair<const Type *, ShadowDSNode *> > SynthNodes;
DSNode(const DSNode &); // DO NOT IMPLEMENT DSNode(const DSNode &); // DO NOT IMPLEMENT
void operator=(const DSNode &); // DO NOT IMPLEMENT void operator=(const DSNode &); // DO NOT IMPLEMENT
public: public:
@@ -186,6 +189,10 @@ public:
return New; return New;
} }
// synthesizeNode - Create a new shadow node that is to be linked into this
// chain..
//
ShadowDSNode *synthesizeNode(const Type *Ty, FunctionRepBuilder *Rep);
virtual void dropAllReferences() { virtual void dropAllReferences() {
FieldLinks.clear(); FieldLinks.clear();
@@ -320,30 +327,25 @@ private:
// //
class ShadowDSNode : public DSNode { class ShadowDSNode : public DSNode {
friend class FunctionDSGraph; friend class FunctionDSGraph;
friend class FunctionRepBuilder;
Module *Mod; Module *Mod;
ShadowDSNode *ShadowParent; // Nonnull if this is a synthesized node... DSNode *ShadowParent; // Nonnull if this is a synthesized node...
std::vector<std::pair<const Type *, ShadowDSNode *> > SynthNodes;
public: public:
ShadowDSNode(const Type *Ty, Module *M); ShadowDSNode(const Type *Ty, Module *M);
virtual std::string getCaption() const; virtual std::string getCaption() const;
// synthesizeNode - Create a new shadow node that is to be linked into this
// chain..
//
ShadowDSNode *synthesizeNode(const Type *Ty, FunctionRepBuilder *Rep);
// isEquivalentTo - Return true if the nodes should be merged... // isEquivalentTo - Return true if the nodes should be merged...
virtual bool isEquivalentTo(DSNode *Node) const; virtual bool isEquivalentTo(DSNode *Node) const;
DSNode *getShadowParent() const { return ShadowParent; }
// Support type inquiry through isa, cast, and dyn_cast... // Support type inquiry through isa, cast, and dyn_cast...
static bool classof(const ShadowDSNode *) { return true; } static bool classof(const ShadowDSNode *) { return true; }
static bool classof(const DSNode *N) { return N->NodeType == ShadowNode; } static bool classof(const DSNode *N) { return N->NodeType == ShadowNode; }
private: private:
ShadowDSNode(const Type *Ty, Module *M, ShadowDSNode *ShadParent); ShadowDSNode(const Type *Ty, Module *M, DSNode *ShadParent);
protected: protected:
virtual void mapNode(std::map<const DSNode*, DSNode*> &NodeMap,
const DSNode *Old);
virtual ShadowDSNode *cloneImpl() const { virtual ShadowDSNode *cloneImpl() const {
if (ShadowParent) if (ShadowParent)
return new ShadowDSNode(getType(), Mod, ShadowParent); return new ShadowDSNode(getType(), Mod, ShadowParent);

View File

@@ -20,6 +20,7 @@ class GlobalValue;
class FunctionDSGraph; class FunctionDSGraph;
class DataStructure; class DataStructure;
class DSNodeIterator; class DSNodeIterator;
class ShadowDSNode;
// FIXME: move this somewhere private // FIXME: move this somewhere private
unsigned countPointerFields(const Type *Ty); unsigned countPointerFields(const Type *Ty);
@@ -114,6 +115,8 @@ class DSNode {
std::vector<Value*> Pointers; // Values pointing to me... std::vector<Value*> Pointers; // Values pointing to me...
std::vector<PointerValSet*> Referrers; std::vector<PointerValSet*> Referrers;
std::vector<std::pair<const Type *, ShadowDSNode *> > SynthNodes;
DSNode(const DSNode &); // DO NOT IMPLEMENT DSNode(const DSNode &); // DO NOT IMPLEMENT
void operator=(const DSNode &); // DO NOT IMPLEMENT void operator=(const DSNode &); // DO NOT IMPLEMENT
public: public:
@@ -186,6 +189,10 @@ public:
return New; return New;
} }
// synthesizeNode - Create a new shadow node that is to be linked into this
// chain..
//
ShadowDSNode *synthesizeNode(const Type *Ty, FunctionRepBuilder *Rep);
virtual void dropAllReferences() { virtual void dropAllReferences() {
FieldLinks.clear(); FieldLinks.clear();
@@ -320,30 +327,25 @@ private:
// //
class ShadowDSNode : public DSNode { class ShadowDSNode : public DSNode {
friend class FunctionDSGraph; friend class FunctionDSGraph;
friend class FunctionRepBuilder;
Module *Mod; Module *Mod;
ShadowDSNode *ShadowParent; // Nonnull if this is a synthesized node... DSNode *ShadowParent; // Nonnull if this is a synthesized node...
std::vector<std::pair<const Type *, ShadowDSNode *> > SynthNodes;
public: public:
ShadowDSNode(const Type *Ty, Module *M); ShadowDSNode(const Type *Ty, Module *M);
virtual std::string getCaption() const; virtual std::string getCaption() const;
// synthesizeNode - Create a new shadow node that is to be linked into this
// chain..
//
ShadowDSNode *synthesizeNode(const Type *Ty, FunctionRepBuilder *Rep);
// isEquivalentTo - Return true if the nodes should be merged... // isEquivalentTo - Return true if the nodes should be merged...
virtual bool isEquivalentTo(DSNode *Node) const; virtual bool isEquivalentTo(DSNode *Node) const;
DSNode *getShadowParent() const { return ShadowParent; }
// Support type inquiry through isa, cast, and dyn_cast... // Support type inquiry through isa, cast, and dyn_cast...
static bool classof(const ShadowDSNode *) { return true; } static bool classof(const ShadowDSNode *) { return true; }
static bool classof(const DSNode *N) { return N->NodeType == ShadowNode; } static bool classof(const DSNode *N) { return N->NodeType == ShadowNode; }
private: private:
ShadowDSNode(const Type *Ty, Module *M, ShadowDSNode *ShadParent); ShadowDSNode(const Type *Ty, Module *M, DSNode *ShadParent);
protected: protected:
virtual void mapNode(std::map<const DSNode*, DSNode*> &NodeMap,
const DSNode *Old);
virtual ShadowDSNode *cloneImpl() const { virtual ShadowDSNode *cloneImpl() const {
if (ShadowParent) if (ShadowParent)
return new ShadowDSNode(getType(), Mod, ShadowParent); return new ShadowDSNode(getType(), Mod, ShadowParent);