Skip to content

Issue #2078 #2092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions vpr/src/route/route_tree_timing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static t_linked_rt_edge* rt_edge_free_list = nullptr;

static t_rt_node* alloc_rt_node();

static void free_rt_node(t_rt_node* rt_node);
static void free_rt_node(t_rt_node** rt_node);

static t_linked_rt_edge* alloc_linked_rt_edge();

Expand Down Expand Up @@ -144,11 +144,15 @@ alloc_rt_node() {
return (rt_node);
}

static void free_rt_node(t_rt_node* rt_node) {
/* After putting the rt_node to the free list, rt_node pointer would be set to
* nullptr to make sure that it does not get double frees if a caller tries to
* free the routing tree twice */
static void free_rt_node(t_rt_node** rt_node) {
/* Adds rt_node to the proper free list. */

rt_node->u.next = rt_node_free_list;
rt_node_free_list = rt_node;
(*rt_node)->u.next = rt_node_free_list;
rt_node_free_list = (*rt_node);
(*rt_node) = nullptr;
}

static t_linked_rt_edge*
Expand Down Expand Up @@ -658,9 +662,9 @@ bool verify_route_tree_recurr(t_rt_node* node, std::set<int>& seen_nodes) {
}

void free_route_tree(t_rt_node* rt_node) {
/* Puts the rt_nodes and edges in the tree rooted at rt_node back on the
* free lists. Recursive, depth-first post-order traversal. */

if (rt_node == nullptr) {
return;
}
t_linked_rt_edge *rt_edge, *next_edge;

rt_edge = rt_node->u.child_list;
Expand All @@ -677,7 +681,7 @@ void free_route_tree(t_rt_node* rt_node) {
rr_node_to_rt_node.at(rt_node->inode) = nullptr;
}

free_rt_node(rt_node);
free_rt_node(&rt_node);
}

void print_route_tree(const t_rt_node* rt_node) {
Expand Down Expand Up @@ -1056,7 +1060,7 @@ static t_rt_node* prune_route_tree_recurr(t_rt_node* node, CBRR& connections_inf
//Record as not reached
connections_inf.toreach_rr_sink(node->net_pin_index);

free_rt_node(node);
free_rt_node(&node);
return nullptr; //Pruned
}
} else if (all_children_pruned) {
Expand Down Expand Up @@ -1102,7 +1106,7 @@ static t_rt_node* prune_route_tree_recurr(t_rt_node* node, CBRR& connections_inf
if (reached_non_configurably && !force_prune) {
return node; //Not pruned
} else {
free_rt_node(node);
free_rt_node(&node);
return nullptr; //Pruned
}

Expand Down
4 changes: 4 additions & 0 deletions vpr/src/route/route_tree_timing.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ void free_route_tree_timing_structs();

t_rt_node* init_route_tree_to_source(ClusterNetId inet);

/*
* Puts the rt_nodes and edges in the tree rooted at rt_node back on the
* free lists. Recursive, depth-first post-order traversal.
*/
void free_route_tree(t_rt_node* rt_node);
void print_route_tree(const t_rt_node* rt_node);
void print_route_tree(const t_rt_node* rt_node, int depth);
Expand Down