Add an EvalOrAddInst function. (#5258)

Use that instead of `AddInstInNoBlock` to get the value of an
instruction when evaluation might depend on the `InstId` but only the
`ConstantId` of the instruction is desired by the consumer.
This commit is contained in:
Richard Smith authored and GitHub committed 2025-04-08 21:04:30 +00:00
1 parent d07f70cfb3
commit bfef32b482
17 files changed
+164 -83

No files matched your search

+2 -1
View File
@@ -1744,7 +1744,8 @@ static auto TryEvalTypedInst(EvalContext& eval_context, SemIR::InstId inst_id,
// Couldn't perform the action because it's still dependent.
return MakeConstantResult(eval_context.context(), inst,
Phase::TemplateSymbolic);
} else if constexpr (InstT::Kind.constant_needs_inst_id()) {
} else if constexpr (InstT::Kind.constant_needs_inst_id() !=
SemIR::InstConstantNeedsInstIdKind::No) {
CARBON_CHECK(inst_id.has_value());
return ConvertEvalResultToConstantId(
eval_context.context(),