mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 13:01:04 +01:00
Fix lowering of a conversion from a type with a pointer value representation to a type with a copy value representation. (#4467)
We previously generated a `value_bind` instruction of the wrong type, resulting in lowering building bad LLVM IR. Also fix another issue exposed by this change, where we would import constants without marking their types as complete, and then crash in lowering while trying to lower them. This happens in particular for the `FunctionType`s of functions in `ImplDecl`s. Address this by skipping lowering for constants with incomplete types.
This commit is contained in:
@@ -260,6 +260,12 @@ auto LowerConstants(FileContext& file_context,
|
||||
}
|
||||
|
||||
auto inst = file_context.sem_ir().insts().Get(inst_id);
|
||||
if (inst.type_id().is_valid() &&
|
||||
!file_context.sem_ir().types().IsComplete(inst.type_id())) {
|
||||
// If a constant doesn't have a complete type, that means we imported it
|
||||
// but didn't actually use it.
|
||||
continue;
|
||||
}
|
||||
llvm::Constant* value = nullptr;
|
||||
CARBON_KIND_SWITCH(inst) {
|
||||
#define CARBON_SEM_IR_INST_KIND(Name) \
|
||||
|
||||
Reference in New Issue
Block a user