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
2025-04-08 21:04:30 +00:00
committed by GitHub
parent d07f70cfb3
commit bfef32b482
17 changed files with 164 additions and 83 deletions
+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(),