mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 14:31:04 +01:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user