If the node is inside some frames, get the name of the outermost non-empty frame. Otherwise, get an empty frame name.
| 1076 | // If the node is inside some frames, get the name of the outermost non-empty |
| 1077 | // frame. Otherwise, get an empty frame name. |
| 1078 | Status GetRootFrame(const Node* n, absl::Span<const ControlFlowInfo> cfi_infos, |
| 1079 | absl::string_view* frame) { |
| 1080 | int depth = 0; |
| 1081 | const ControlFlowInfo* cfi_iter = &cfi_infos[n->id()]; |
| 1082 | while (!cfi_iter->parent_frame->IsSource()) { |
| 1083 | n = cfi_iter->parent_frame; |
| 1084 | cfi_iter = &cfi_infos[n->id()]; |
| 1085 | |
| 1086 | if (depth++ > 5000) { |
| 1087 | return errors::Internal( |
| 1088 | "Frame of depth > 5000: Probably malformed graph or a bug in " |
| 1089 | "BuildControlFlowInfo"); |
| 1090 | } |
| 1091 | } |
| 1092 | |
| 1093 | *frame = cfi_iter->frame_name; |
| 1094 | return Status::OK(); |
| 1095 | } |
| 1096 | } // namespace |
| 1097 | |
| 1098 | Status DeadnessAnalysisImpl::HandleMerge(Node* n, |