5 #include "src/compiler/all-nodes.h" 7 #include "src/compiler/graph.h" 13 AllNodes::AllNodes(Zone* local_zone,
const Graph* graph,
bool only_inputs)
14 : reachable(local_zone),
15 is_reachable_(graph->NodeCount(), false, local_zone),
16 only_inputs_(only_inputs) {
17 Mark(local_zone, graph->end(), graph);
20 AllNodes::AllNodes(Zone* local_zone, Node* end,
const Graph* graph,
22 : reachable(local_zone),
23 is_reachable_(graph->NodeCount(), false, local_zone),
24 only_inputs_(only_inputs) {
25 Mark(local_zone, end, graph);
28 void AllNodes::Mark(Zone* local_zone, Node* end,
const Graph* graph) {
29 DCHECK_LT(end->id(), graph->NodeCount());
30 is_reachable_[end->id()] =
true;
31 reachable.push_back(end);
33 for (
size_t i = 0;
i < reachable.size();
i++) {
34 for (Node*
const input : reachable[
i]->inputs()) {
35 if (input ==
nullptr) {
39 if (!is_reachable_[input->id()]) {
40 is_reachable_[input->id()] =
true;
41 reachable.push_back(input);
45 for (Node* use : reachable[
i]->uses()) {
46 if (use ==
nullptr || use->id() >= graph->NodeCount()) {
49 if (!is_reachable_[use->id()]) {
50 is_reachable_[use->id()] =
true;
51 reachable.push_back(use);