message: Optimize symbol lookups in GuaranteeAllFuncsOneUse
  This commit utilizes SymbolUserMap to optimize symbol lookups, greatly reducing the compile time of this pass. In a large TF model, the execution time of the tf-tpu-bridge pipeline was reduced by over 38%.
diff: @@ -63,39 +63,39 @@ class GuaranteeAllFuncsOneUse
  // Overall strategy:
  // Fixed point iteration, iteratively applying a rule that clones
  // any FuncOp with more than one use to eliminate its uses.
  -
  - SymbolTable symbol_table(module);
  + SymbolTableCollection symbol_table_collection;
  + SymbolTable &symbol_table = symbol_table_collection.getSymbolTable(module);
  bool made_changes = false;
  +
  // This value needs to be low enough to actually stop compilation in a
  // reasonable time, but not too low that it blocks real programs.
  // This number was chosen semi-randomly.
  const int k_max_clones = 1000;
  int num_clones = 0;
  do {
  + SymbolUserMap symbol_users(symbol_table_collection, module);
  +
  made_changes = false;
  for (auto func : llvm::make_early_inc_range(module.getOps<FuncOp>())) {
  - auto uses_optional = symbol_table.getSymbolUses(func, module);
  - if (!uses_optional.hasValue()) {
  - return func.emitError() << "could not walk uses of func";
  - }
  - auto &uses = *uses_optional;
  - if (llvm::size(uses) <= 1) {
  + ArrayRef<Operation *> users = symbol_users.getUsers(func);
  + if (users.size() <= 1) {
  continue;
  }
  +
  // At this point, we know we are going to change the module.
  made_changes = true;
  - for (const SymbolTable::SymbolUse &use : llvm::drop_begin(uses, 1)) {
  + for (Operation *user : users.drop_front()) {
  if (num_clones++ > k_max_clones) {
  return func.emitError()
  << "reached cloning limit (likely recursive call graph or "
  "repeated diamond-like call structure "
  "or just very large program)";
  }
  - auto new_func = func.clone();
  + FuncOp new_func = func.clone();
  symbol_table.insert(new_func);
  new_func.setPrivate();
  - if (failed(symbol_table.replaceAllSymbolUses(func, new_func.getName(),
  - use.getUser()))) {
  + if (failed(SymbolTable::replaceAllSymbolUses(func, new_func.getName(),
  + user))) {
  return func.emitError() << "could not replace symbol use";
  }
  }
  