Skip to content

Commit

Permalink
More bug fixes. There is one more bug that was detected by bzip2 test
Browse files Browse the repository at this point in the history
case and I have written a reducer to get the minimal constraint set.
However, I still have to look into that reduced set
  • Loading branch information
grievejia committed Apr 3, 2014
1 parent 6d3e9e8 commit 5bbea7d
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion include/CycleDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class CycleDetector
break;

processNodeOnCycle(cycleNode, node);

inComponent.insert(cycleNode);
sccStack.pop();
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Andersen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ void Andersen::dumpConstraint(const AndersConstraint& item) const
case AndersConstraint::LOAD:
{
nodeFactory.dumpNode(dest);
errs() << " = *(";
errs() << " = *";
nodeFactory.dumpNode(src);
break;
}
case AndersConstraint::STORE:
{
errs() << "*";
nodeFactory.dumpNode(dest);
errs() << " = (";
errs() << " = ";
nodeFactory.dumpNode(src);
break;
}
Expand Down
40 changes: 31 additions & 9 deletions lib/ConstraintOptimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,32 +463,54 @@ class HUOptimizer: public ConstraintOptimizer
// Map from NodeIndex to its offline pts-set
DenseMap<unsigned, SparseBitVector<>> ptsSet;

void propagateLabel(NodeIndex node) override
// Try to assign a single label to node. Return true if the assignment succeeds
bool assignLabel(NodeIndex node)
{
// ADR nodes get a unique label and a pts-set that contains the corresponding VAR node
if (node >= nodeFactory.getNumNodes() * 2)
{
peLabel[node] = pointerEqClass++;
ptsSet[node].set(node - nodeFactory.getNumNodes() * 2);
return;
return true;
}

// REF nodes get a unique label and a pts-set that contains itself (which can never collide with VAR nodes)
if (node >= nodeFactory.getNumNodes())
{
peLabel[node] = pointerEqClass++;
ptsSet[node].set(node);
return;
return true;
}

// Indirect VAR nodes get a unique label and a pts-set that contains its corresponding ADR node (which can never collide with VAR and REF nodes)
if (indirectNodes.count(node))
{
peLabel[node] = pointerEqClass++;
ptsSet[node].set(getAdrNodeIndex(node));
return;
return true;
}

return false;
}

// Note that ConstraintOptimizer::processNodeOnCycle() is not enough here, because when we merge two nodes we also want the ptsSet of these two nodes to be merged.
void processNodeOnCycle(const NodeType* node, const NodeType* repNode) override
{
ConstraintOptimizer::processNodeOnCycle(node, repNode);

if (!assignLabel(node->getNodeIndex()))
return;

auto itr = ptsSet.find(node->getNodeIndex());
if (itr != ptsSet.end())
ptsSet[repNode->getNodeIndex()] |= itr->second;
}

void propagateLabel(NodeIndex node) override
{
if (assignLabel(node))
return;

// Direct VAR nodes need more careful examination
SparseBitVector<>& myPtsSet = ptsSet[node];
SparseBitVectorGraphNode* sNode = predGraph.getNodeWithIndex(node);
Expand Down Expand Up @@ -545,23 +567,23 @@ class HUOptimizer: public ConstraintOptimizer
void Andersen::optimizeConstraints()
{
//errs() << "\n#constraints = " << constraints.size() << "\n";
//dumpConstraints();
dumpConstraints();

// First, let's do HVN
// There is an additional assumption here that before HVN, we have not merged any two nodes. Might fix that in the future
HVNOptimizer hvn(constraints, nodeFactory);
hvn.run();
hvn.releaseMemory();

//nodeFactory.dumpRepInfo();
//dumpConstraints();
nodeFactory.dumpRepInfo();
dumpConstraints();

//errs() << "#constraints = " << constraints.size() << "\n";

// Next, do HU
// There is an additional assumption here that before HU, the predecessor graph will have no cycle. Might fix that in the future
HUOptimizer hu(constraints, nodeFactory);
hu.run();
//HUOptimizer hu(constraints, nodeFactory);
//hu.run();

//nodeFactory.dumpRepInfo();
//dumpConstraints();
Expand Down
8 changes: 5 additions & 3 deletions lib/ConstraintSolving.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ void collapseNodes(NodeIndex dst, NodeIndex src, AndersNodeFactory& nodeFactory,

// Node merge
nodeFactory.mergeNode(dst, src);
ptsGraph[dst].unionWith(ptsGraph[src]);
if (ptsGraph.count(src))
ptsGraph[dst].unionWith(ptsGraph[src]);
constraintGraph.mergeNodes(dst, src);

// We don't need the node cycleIdx any more
Expand Down Expand Up @@ -607,7 +608,7 @@ void Andersen::solveConstraints()
NodeIndex tgtNode = nodeFactory.getMergeTarget(dst);
if (constraintGraph.insertCopyEdge(tgtNode, vRep))
{
//errs() << "\tInsert copy edge " << tgtNode << " -> " << v << ", offset = " << offset << "\n";
//errs() << "\tInsert copy edge " << tgtNode << " -> " << v << "\n";
nextWorkList->enqueue(tgtNode);
}

Expand All @@ -626,9 +627,10 @@ void Andersen::solveConstraints()
for (auto const& dst: *cNode)
{
NodeIndex tgtNode = nodeFactory.getMergeTarget(dst);
AndersPtsSet& tgtPtsSet = ptsGraph[tgtNode];
if (node == tgtNode)
continue;
AndersPtsSet& tgtPtsSet = ptsGraph[tgtNode];

//errs() << "pts[" << tgtNode << "] |= pts[" << node << "]\n";
bool isChanged = tgtPtsSet.unionWith(ptsSet);

Expand Down

0 comments on commit 5bbea7d

Please sign in to comment.