> /* below I pass a the tree of the current_function_decl a global > variable in tree.h */ > this_cfun = DECL_STRUCT_FUNCTION(current_function_decl); > FOR_EACH_BB_FN(bb, this_cfun) /* Crashes here, Also tried with > FOR_EACH_BB */ > for (bsi = bsi_start(bb); !bsi_end_p(bsi); bsi_next(&bsi)) > { > bsi_stmt(bsi); > } > bsi = bsi_for_stmt(current_function_decl); /* Crashes right here */ > }
bsi_for_stmt(current_function_decl); does not seems correct to me as it should return the function's declaration's basic block iterator; which does not belongs to bb. I think you are also missing some statement to get the current tree node in the loop: tree stmt = bsi_stmt (bsi); and later recursively manipulate it with walk_tree (). Please look how it is done in cgraph_create_edges(). Revital