From b289a1a05429acdf265f27b89ba75001dbcd19d6 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 17 Aug 2018 15:49:03 -0700 Subject: [PATCH] bug fix --- src/ASTAnalyses/Encoding/encodinggraph.cc | 24 ++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/ASTAnalyses/Encoding/encodinggraph.cc b/src/ASTAnalyses/Encoding/encodinggraph.cc index ebb8a96..45ae01a 100644 --- a/src/ASTAnalyses/Encoding/encodinggraph.cc +++ b/src/ASTAnalyses/Encoding/encodinggraph.cc @@ -77,10 +77,11 @@ void EncodingGraph::encode() { encoding->encodingArrayInitialization(); } else if (encodetype == BINARYINDEX) { EncodingSubGraph *subgraph = graphMap.get(n); - DEBUG("graphMap.get(subgraph=%p, n=%p)\n", subgraph, n); + DEBUG("graphMap.get(subgraph=%p, n=%p)\n", subgraph, n); if (subgraph == NULL) { - continue; - } + encoding->encodingArrayInitialization(); + continue; + } uint encodingSize = subgraph->getEncodingMaxVal(n) + 1; uint paddedSize = encoding->getSizeEncodingArray(encodingSize); encoding->allocInUseArrayElement(paddedSize); @@ -131,9 +132,9 @@ void EncodingGraph::encodeParent(Element *e) { void EncodingGraph::mergeNodes(EncodingNode *first, EncodingNode *second) { EncodingSubGraph *graph1 = graphMap.get(first); - DEBUG("graphMap.get(first=%p, graph1=%p)\n", first, graph1); + DEBUG("graphMap.get(first=%p, graph1=%p)\n", first, graph1); EncodingSubGraph *graph2 = graphMap.get(second); - DEBUG("graphMap.get(second=%p, graph2=%p)\n", second, graph2); + DEBUG("graphMap.get(second=%p, graph2=%p)\n", second, graph2); if (graph1 == NULL) first->setEncoding(BINARYINDEX); if (graph2 == NULL) @@ -142,7 +143,7 @@ void EncodingGraph::mergeNodes(EncodingNode *first, EncodingNode *second) { if (graph1 == NULL && graph2 == NULL) { graph1 = new EncodingSubGraph(); subgraphs.add(graph1); - DEBUG("graphMap.put(first=%p, graph1=%p)\n", first, graph1); + DEBUG("graphMap.put(first=%p, graph1=%p)\n", first, graph1); graphMap.put(first, graph1); graph1->addNode(first); } @@ -158,17 +159,17 @@ void EncodingGraph::mergeNodes(EncodingNode *first, EncodingNode *second) { while (nodeit->hasNext()) { EncodingNode *node = nodeit->next(); graph1->addNode(node); - DEBUG("graphMap.put(node=%p, graph1=%p)\n", node, graph1); + DEBUG("graphMap.put(node=%p, graph1=%p)\n", node, graph1); graphMap.put(node, graph1); } subgraphs.remove(graph2); delete nodeit; - DEBUG("Deleting graph2 =%p \n", graph2); + DEBUG("Deleting graph2 =%p \n", graph2); delete graph2; } else { ASSERT(graph1 != NULL && graph2 == NULL); graph1->addNode(second); - DEBUG("graphMap.put(first=%p, graph1=%p)\n", first, graph1); + DEBUG("graphMap.put(first=%p, graph1=%p)\n", first, graph1); graphMap.put(second, graph1); } } @@ -282,6 +283,11 @@ void EncodingGraph::decideEdges() { (newSize - rightSize) * right->elements.getSize(); } else { //Neither are null + + //Are we already merged? + if (leftGraph == rightGraph) + continue; + leftSize = convertSize(leftGraph->encodingSize); rightSize = convertSize(rightGraph->encodingSize); newSize = convertSize(leftGraph->estimateNewSize(rightGraph)); -- 2.34.1