mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 06:51:05 +01:00
Fix lowering crash when a SpecificInst's inst_id doesn't emit a value (#7880)
This commit is contained in:
@@ -174,7 +174,8 @@ auto FunctionContext::IsConstant(SemIR::InstId inst_id) -> bool {
|
||||
.second.is_constant();
|
||||
}
|
||||
|
||||
auto FunctionContext::GetValue(SemIR::InstId inst_id) -> llvm::Value* {
|
||||
auto FunctionContext::GetValue(SemIR::InstId inst_id, bool require_value)
|
||||
-> llvm::Value* {
|
||||
// Singletons are types, as is the builtin TypeType, with the same empty
|
||||
// lowered value.
|
||||
if (SemIR::IsSingletonInstId(inst_id) ||
|
||||
@@ -193,9 +194,17 @@ auto FunctionContext::GetValue(SemIR::InstId inst_id) -> llvm::Value* {
|
||||
auto [const_ir, const_id] = GetConstantValueInSpecific(
|
||||
specific_sem_ir(), specific_id_, sem_ir(), inst_id);
|
||||
CARBON_CHECK(const_ir == &sem_ir() || const_ir == &specific_sem_ir());
|
||||
CARBON_CHECK(const_id.is_concrete(),
|
||||
"Missing value: {0} {1} in {2} has non-concrete value {3}",
|
||||
inst_id, sem_ir().insts().Get(inst_id), specific_id_, const_id);
|
||||
if (require_value) {
|
||||
CARBON_CHECK(const_id.is_concrete(),
|
||||
"Missing value: {0} {1} in {2} has non-concrete value {3}",
|
||||
inst_id, sem_ir().insts().Get(inst_id), specific_id_,
|
||||
const_id);
|
||||
}
|
||||
|
||||
if (!const_id.is_concrete()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// We can only pass on the InstId if it refers to the file in which the
|
||||
// constant value was provided.
|
||||
auto* global = GetFileContext(const_ir).GetConstant(
|
||||
|
||||
Reference in New Issue
Block a user