Preserve source locations in imported eval blocks (#5213)

Don't lose track of where the instructions in an eval block are across
import.
This commit is contained in:
Richard Smith
2025-03-28 23:41:40 +00:00
committed by GitHub
parent 4cb61ae4e1
commit 660d62ecc1
5 changed files with 43 additions and 23 deletions
+12 -2
View File
@@ -3108,8 +3108,18 @@ static auto ResolveLocalEvalBlock(ImportRefResolver& resolver,
}
auto inst_ids = ResolveLocalInstBlockContents(resolver, import_block_id);
return RebuildGenericEvalBlock(resolver.local_context(), generic_id, region,
inst_ids);
auto eval_block_id = RebuildGenericEvalBlock(resolver.local_context(),
generic_id, region, inst_ids);
// Set the locations of the instructions in the inst block to match those of
// the imported instructions.
for (auto [import_inst_id, local_inst_id] :
llvm::zip(resolver.import_inst_blocks().Get(import_block_id),
resolver.local_inst_blocks().Get(eval_block_id))) {
auto import_ir_inst_id = AddImportIRInst(resolver, import_inst_id);
resolver.local_insts().SetLocId(local_inst_id, import_ir_inst_id);
}
return eval_block_id;
}
// Fills in the remaining information in a partially-imported generic.