示例#1
0
void IR_GVN::clean()
{
	m_vn_count = 1;
	if (m_md2vn.get_bucket_size() != 0) {
		m_md2vn.clean();
	}
	if (m_ll2vn.get_bucket_size() != 0) {
		m_ll2vn.clean();
	}
	if (m_fp2vn.get_bucket_size() != 0) {
		m_fp2vn.clean();
	}
	if (m_str2vn.get_bucket_size() != 0) {
		m_str2vn.clean();
	}
	BITSET inlst;
	for (INT k = 0; k <= m_ir2vn.get_last_idx(); k++) {
		VN * x = m_ir2vn.get(k);
		if (x != NULL && !inlst.is_contain(VN_id(x))) {
			inlst.bunion(VN_id(x));
			m_free_lst.append_tail(x);
		}
	}
	m_ir2vn.clean();
	for (SVECTOR<VN*> * v = m_vnvec_lst.get_head();
		 v != NULL; v = m_vnvec_lst.get_next()) {
		v->clean();
	}

	m_def2ildtab.clean();
	m_def2arrtab.clean();
	m_def2sctab.clean();
	m_stmt2domdef.clean();
	m_zero_vn = NULL;
}
示例#2
0
void DGRAPH::_remove_unreach_node(UINT id, BITSET & visited)
{
	visited.bunion(id);
	VERTEX * vex = get_vertex(id);
	EDGE_C * el = VERTEX_out_list(vex);	
	while (el != NULL) {
		UINT succ = VERTEX_id(EDGE_to(EC_edge(el)));
		if (!visited.is_contain(succ)) {
			_remove_unreach_node(succ, visited);
		}	
		el = EC_next(el);
	}
}
示例#3
0
bool GRAPH::is_equal(GRAPH & g)
{
	if (get_vertex_num() != g.get_vertex_num() ||
		get_edge_num() != g.get_edge_num()) {
		return false;
	}
	
	BITSET vs;
	INT c;
	for (VERTEX * v1 = get_first_vertex(c); 
		 v1 != NULL; v1 = get_next_vertex(c)) {
		VERTEX * v2 = g.get_vertex(VERTEX_id(v1));
		if (v2 == NULL) {
			return false; 
		}

		vs.clean();
		EDGE_C * el = VERTEX_out_list(v1);		
		EDGE * e = NULL;
		UINT v1_succ_n = 0;
		if (el == NULL) {
			if (VERTEX_out_list(v2) != NULL) {
				return false;
			}
			continue;
		}
		for (e = EC_edge(el); e != NULL; el = EC_next(el), 
			 e = el ? EC_edge(el) : NULL) {
			vs.bunion(VERTEX_id(EDGE_to(e)));
			v1_succ_n++;
		}

		UINT v2_succ_n = 0;
		el = VERTEX_out_list(v2);
		for (e = EC_edge(el); e != NULL; el = EC_next(el), 
			 e = el ? EC_edge(el) : NULL) {
			v2_succ_n++;
			if (!vs.is_contain(VERTEX_id(EDGE_to(e)))) {
				return false;
			}			
		}
		
		if (v1_succ_n != v2_succ_n) { 
			return false; 
		}
	}
	return true;
}
示例#4
0
/*
Perform DFS to seek for unreachable node.
Return true if some nodes removed.
*/
bool DGRAPH::remove_unreach_node(UINT entry_id)
{
	if (get_vertex_num() == 0) return false;
	bool removed = false;
	BITSET visited;
	_remove_unreach_node(entry_id, visited);
	INT c;
	for (VERTEX * v = get_first_vertex(c); 
		 v != NULL; v = get_next_vertex(c)) {
		if (!visited.is_contain(VERTEX_id(v))) {
			remove_vertex(v);
			removed = true;
		}
	}
	return removed;
}