Create a control dependency var that connects 2 operations. The var doesn't hold any data. Other than that, it's no different from other var, considering dependency analysis.
| 267 | // var doesn't hold any data. Other than that, it's no different from |
| 268 | // other var, considering dependency analysis. |
| 269 | ir::Node *CreateControlDepVar() { |
| 270 | if (FLAGS_convert_all_blocks) { |
| 271 | if (IsMainGraph()) { |
| 272 | return GetSubGraph(0)->CreateControlDepVar(); |
| 273 | } |
| 274 | } |
| 275 | // TODO(panyx0718): control var name should be really unique. |
| 276 | const std::string name = |
| 277 | string::Sprintf("%s@%llu", |
| 278 | static_cast<const char *>(ir::Node::kControlDepVarName), |
| 279 | num_node_created_); |
| 280 | auto *x = AddNode(new ir::Node(name, ir::Node::Type::kVariable, block_id_)); |
| 281 | x->SetId(num_node_created_++); |
| 282 | x->SetGraphId(block_id_); |
| 283 | return x; |
| 284 | } |
| 285 | |
| 286 | // A more free style way of creating a graph node. Mostly use for test |
| 287 | // or "copy" from another node. Avoid using it if possible. |