Skip to content

Commit 5cbee79

Browse files
Sean Purser-Haskellcopybara-github
authored andcommitted
Fix for timeouts
PiperOrigin-RevId: 863274693
1 parent 1898ab2 commit 5cbee79

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

xls/contrib/xlscc/continuations.cc

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,15 @@ OptimizationContext::GetSourcesSetTreeNodeInfoForFunction(
278278
return sources_set_tree_node_infos_by_function_.at(in_function).get();
279279
}
280280

281+
const xls::LeafTypeTree<std::monostate>&
282+
OptimizationContext::GetBlankTypeTreeForType(xls::Type* type) {
283+
CHECK_NE(type, nullptr);
284+
auto [param_tree_it, _] = param_tree_cache_.try_emplace(type, type);
285+
xls::LeafTypeTree<std::monostate>& found = param_tree_it->second;
286+
CHECK(found.type()->IsEqualTo(type));
287+
return found;
288+
}
289+
281290
absl::StatusOr<bool> OptimizationContext::CheckNodeSourcesInSet(
282291
xls::FunctionBase* in_function, xls::Node* node,
283292
absl::flat_hash_set<const xls::Param*> sources_set,
@@ -1270,12 +1279,10 @@ absl::Status RemoveUnusedContinuationInputs(GeneratedFunction& func,
12701279
}
12711280

12721281
CHECK_EQ(continuation_in.input_node->function_base(), slice.function);
1273-
12741282
if (return_value_from_params.contains(continuation_in.input_node)) {
12751283
++cont_in_it;
12761284
continue;
12771285
}
1278-
12791286
// There may still be uses like forming a tuple, the element of which is
12801287
// never indexed
12811288
XLS_RETURN_IF_ERROR(
@@ -1349,8 +1356,8 @@ FindPassThroughs(GeneratedFunction& func, OptimizationContext& context) {
13491356

13501357
// Check that param has the same number of elements as
13511358
// continuation_out. This avoids marking slices as pass-throughs.
1352-
xls::LeafTypeTree<std::monostate> param_tree(
1353-
source_node->GetType());
1359+
const xls::LeafTypeTree<std::monostate>& param_tree =
1360+
context.GetBlankTypeTreeForType(source_node->GetType());
13541361
if (param_tree.elements().size() != sources.elements().size()) {
13551362
disallowed = true;
13561363
break;

xls/contrib/xlscc/translator_types.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,9 @@ class OptimizationContext {
13021302
absl::StatusOr<xls::PartialInfoQueryEngine*> GetQueryEngineForFunction(
13031303
xls::FunctionBase* in_function);
13041304

1305+
const xls::LeafTypeTree<std::monostate>& GetBlankTypeTreeForType(
1306+
xls::Type* type);
1307+
13051308
absl::StatusOr<bool> CheckNodeSourcesInSet(
13061309
xls::FunctionBase* in_function, xls::Node* node,
13071310
absl::flat_hash_set<const xls::Param*> sources_set,
@@ -1315,6 +1318,9 @@ class OptimizationContext {
13151318
std::unique_ptr<SourcesSetTreeNodeInfo>>
13161319
sources_set_tree_node_infos_by_function_;
13171320

1321+
absl::flat_hash_map<xls::Type*, xls::LeafTypeTree<std::monostate>>
1322+
param_tree_cache_;
1323+
13181324
absl::flat_hash_map<xls::FunctionBase*,
13191325
std::unique_ptr<xls::PartialInfoQueryEngine>>
13201326
query_engines_by_function_;

0 commit comments

Comments
 (0)