Don't try to infer where to put loads in lowering. (#3146)

Trust semantics to have put them in the right places.

Many parts of lowering still need to be updated to use the value
representation chosen at the semantics layer, but this is an incremental
step towards that.
This commit is contained in:
Richard Smith
2023-10-04 19:57:12 +00:00
committed by GitHub
parent 6833652ffa
commit 1ac7002bf6
15 changed files with 325 additions and 92 deletions
+1 -12
View File
@@ -98,7 +98,7 @@ auto FunctionContext::CopyValue(SemIR::TypeId type_id, SemIR::NodeId source_id,
case SemIR::ValueRepresentation::None:
break;
case SemIR::ValueRepresentation::Copy:
builder().CreateStore(GetLocalLoaded(source_id), GetLocal(dest_id));
builder().CreateStore(GetLocal(source_id), GetLocal(dest_id));
break;
case SemIR::ValueRepresentation::Pointer: {
const auto& layout = llvm_module().getDataLayout();
@@ -118,15 +118,4 @@ auto FunctionContext::CopyValue(SemIR::TypeId type_id, SemIR::NodeId source_id,
}
}
auto FunctionContext::GetLocalLoaded(SemIR::NodeId node_id) -> llvm::Value* {
auto* value = GetLocal(node_id);
if (llvm::isa<llvm::AllocaInst, llvm::GetElementPtrInst>(value)) {
auto* load_type = GetType(semantics_ir().GetNode(node_id).type_id());
return builder().CreateLoad(load_type, value);
} else {
// No load is needed.
return value;
}
}
} // namespace Carbon::Lower