From: Chris Lattner Date: Sun, 10 Nov 2002 07:46:08 +0000 (+0000) Subject: Fix a bug that could trigger when varargs call sites had non-matching number of arguments X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d11e954f0858d45f6e829cf7dbbac9f2c8e6202a;p=oota-llvm.git Fix a bug that could trigger when varargs call sites had non-matching number of arguments git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4683 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index 175cc8a3f7d..67778181ef1 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -773,7 +773,7 @@ static void removeRefsToGlobal(DSNode* N, // bool DSGraph::isNodeDead(DSNode *N) { // Is it a trivially dead shadow node? - return N->getReferrers().empty() && (N->NodeType & ~DSNode::DEAD) == 0 + return N->getReferrers().empty() && (N->NodeType & ~DSNode::DEAD) == 0; } static inline void killIfUselessEdge(DSNodeHandle &Edge) { @@ -831,9 +831,16 @@ static void removeIdenticalCalls(vector &Calls, NumDuplicateCalls > 20) { DSCallSite &OCS = Calls[i-1]; OCS.getRetVal().mergeWith(CS.getRetVal()); - for (unsigned a = 0, e = CS.getNumPtrArgs(); a != e; ++a) + + for (unsigned a = 0, + e = std::min(CS.getNumPtrArgs(), OCS.getNumPtrArgs()); + a != e; ++a) OCS.getPtrArg(a).mergeWith(CS.getPtrArg(a)); // The node will now be eliminated as a duplicate! + if (CS.getNumPtrArgs() < OCS.getNumPtrArgs()) + CS = OCS; + else if (CS.getNumPtrArgs() > OCS.getNumPtrArgs()) + OCS = CS; } } else { LastCalleeNode = CS.getCallee().getNode();