From 6088c4f55e1ad0efefc0bc3739756ddbebf92899 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 27 Mar 2002 19:46:05 +0000 Subject: [PATCH] * Implement DSNode::removeAllIncomingEdges * Implement Critical Shadow node handling * Implement routines to determine whether an allocation node is a malloc or alloca git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2003 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/DataStructure/NodeImpl.cpp | 26 +++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/Analysis/DataStructure/NodeImpl.cpp b/lib/Analysis/DataStructure/NodeImpl.cpp index 30bc9d21df2..967c67eea0f 100644 --- a/lib/Analysis/DataStructure/NodeImpl.cpp +++ b/lib/Analysis/DataStructure/NodeImpl.cpp @@ -65,6 +65,13 @@ void DSNode::removeReferrer(PointerValSet *PVS) { } +// removeAllIncomingEdges - Erase all edges in the graph that point to this node +void DSNode::removeAllIncomingEdges() { + while (!Referrers.empty()) + Referrers.back()->removePointerTo(this); +} + + static void replaceIn(std::string &S, char From, const std::string &To) { for (unsigned i = 0; i < S.size(); ) if (S[i] == From) { @@ -145,12 +152,14 @@ NewDSNode::NewDSNode(AllocationInst *V) : DSNode(NewNode, V->getType()->getElementType()), Allocation(V) { } +bool NewDSNode::isAllocaNode() const { + return isa(Allocation); +} + + string NewDSNode::getCaption() const { stringstream OS; - if (isa(Allocation)) - OS << "new "; - else - OS << "alloca "; + OS << (isMallocNode() ? "new " : "alloca "); WriteTypeSymbolic(OS, getType(), Allocation->getParent()->getParent()->getParent()); @@ -170,11 +179,12 @@ string GlobalDSNode::getCaption() const { } -ShadowDSNode::ShadowDSNode(DSNode *P, Module *M) +ShadowDSNode::ShadowDSNode(DSNode *P, Module *M, bool C = false) : DSNode(ShadowNode, cast(P->getType())->getElementType()) { Parent = P; Mod = M; ShadowParent = 0; + CriticalNode = C; } ShadowDSNode::ShadowDSNode(const Type *Ty, Module *M, ShadowDSNode *ShadParent) @@ -182,12 +192,16 @@ ShadowDSNode::ShadowDSNode(const Type *Ty, Module *M, ShadowDSNode *ShadParent) Parent = 0; Mod = M; ShadowParent = ShadParent; + CriticalNode = false; } std::string ShadowDSNode::getCaption() const { stringstream OS; + if (CriticalNode) OS << "# "; + OS << "shadow "; WriteTypeSymbolic(OS, getType(), Mod); - return "shadow " + OS.str(); + if (CriticalNode) OS << " #"; + return OS.str(); } void ShadowDSNode::mapNode(map &NodeMap,