From c55c3e8a57c7c6f2f67a486a2a8ffb19cf1c6553 Mon Sep 17 00:00:00 2001 From: Eric Astor Date: Thu, 10 Aug 2023 10:45:35 -0700 Subject: [PATCH] Improve error reporting from codegen scheduling failures Replaces a QFATAL log line, instead constructing a Status containing more error details to be passed up to final error handling. Also fixes a case (at least one of `pipeline_stages` and `clock_period_ps` unspecified) where we accidentally discarded the error and crashed with an XLS_RET_CHECK. PiperOrigin-RevId: 555559547 --- xls/tools/codegen_main.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/xls/tools/codegen_main.cc b/xls/tools/codegen_main.cc index 8a4c6aa241..51353c7ba1 100644 --- a/xls/tools/codegen_main.cc +++ b/xls/tools/codegen_main.cc @@ -186,18 +186,19 @@ absl::StatusOr RunSchedulingPipeline( if (absl::IsResourceExhausted(scheduling_status)) { // Resource exhausted error indicates that the schedule was // infeasible. Emit a meaningful error in this case. - if (scheduling_options.pipeline_stages().has_value() && - scheduling_options.clock_period_ps().has_value()) { - // TODO(meheff): Add link to documentation with more information and - // guidance. - XLS_LOG(QFATAL) << absl::StreamFormat( - "Design cannot be scheduled in %d stages with a %dps clock.", - scheduling_options.pipeline_stages().value(), - scheduling_options.clock_period_ps().value()); + std::string error_message = "Design cannot be scheduled"; + if (scheduling_options.pipeline_stages().has_value()) { + absl::StrAppendFormat(&error_message, " in %d stages", + scheduling_options.pipeline_stages().value()); } - } else { - return scheduling_status; + if (scheduling_options.clock_period_ps().has_value()) { + absl::StrAppendFormat(&error_message, " with a %dps clock", + scheduling_options.clock_period_ps().value()); + } + return xabsl::StatusBuilder(scheduling_status).SetPrepend() + << error_message << ": "; } + return scheduling_status; } XLS_RET_CHECK(scheduling_unit.schedule.has_value());