tensorflow/compiler/mlir/xla/transforms/legalize_tf_communication.cc
// Collects control flow op ancestors of a given op, up until FuncOp. If any
// ancestor is not a control flow op or a FuncOp, or of a single block region,
// an error will be returned.
Collects control flow op ancestors of a given op, up until FuncOp. If any
ancestor is not a control flow op or a FuncOp, or of a single block region,
an error will be returned.
Collects control flow op ancestors of a given op up until FuncOp . If any ancestor is not a control flow op or a FuncOp or of a single block region an error will be returned .
LogicalResult GetControlFlowAncestors(
    Operation* op, llvm::SmallPtrSetImpl<Operation*>& control_flow_ops,
    llvm::SmallPtrSetImpl<Block*>& control_flow_blocks) {
  Block* block = op->getBlock();
  Operation* parent = block->getParentOp();
  while (block && parent && !isa<FuncOp>(parent)) {
    if (!IsControlFlowOp(parent))
      return op->emitOpError()
             << "expects ancestor(s) to be of ['" << IfOp::getOperationName()
             << "', '" << FuncOp::getOperationName() << "']";
    if (!llvm::hasSingleElement(block->getParent()->getBlocks()))
      return op->emitOpError() << "expects single block region ancestor(s)";
    control_flow_ops.insert(parent);
    control_flow_blocks.insert(block);
    parent = block->getParentOp();
    block = parent->getBlock();
  }
  return success();
}
LogicalResult GetControlFlowAncestors ( Operation * op , llvm :: SmallPtrSetImpl < Operation * > & control_flow_ops , llvm :: SmallPtrSetImpl < Block * > & control_flow_blocks ) { Block * block = op -> getBlock ( ) ; Operation * parent = block -> getParentOp ( ) ; while ( block && parent && ! isa < FuncOp > ( parent ) ) { if ( ! IsControlFlowOp ( parent ) ) return op -> emitOpError ( ) << " " << IfOp :: getOperationName ( ) << " " << FuncOp :: getOperationName ( ) << " " ; if ( ! llvm :: hasSingleElement ( block -> getParent ( ) -> getBlocks ( ) ) ) return op -> emitOpError ( ) << " " ; control_flow_ops . insert ( parent ) ; control_flow_blocks . insert ( block ) ; parent = block -> getParentOp ( ) ; block = parent -> getBlock ( ) ; } return success ( ) ; }
Collects control flow op ancestors of a given op, up until FuncOp.
Collects control flow op ancestors of a given op up until FuncOp .