From 4901db832ca804c25532fcecce3494e40751b38f Mon Sep 17 00:00:00 2001 From: Boaz Brickner Date: Thu, 22 May 2025 17:45:10 +0200 Subject: [PATCH] Deduplicate getting the function in `HandleInst()` for `Call` (#5515) Part of #5514. --- toolchain/lower/handle_call.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/toolchain/lower/handle_call.cpp b/toolchain/lower/handle_call.cpp index cd8d8615e752..b32be18b6b11 100644 --- a/toolchain/lower/handle_call.cpp +++ b/toolchain/lower/handle_call.cpp @@ -480,10 +480,10 @@ auto HandleInst(FunctionContext& context, SemIR::InstId inst_id, context.sem_ir(), inst.callee_id, context.specific_id()); CARBON_CHECK(callee_function.function_id.has_value()); - if (auto builtin_kind = context.sem_ir() - .functions() - .Get(callee_function.function_id) - .builtin_function_kind; + const SemIR::Function& function = + context.sem_ir().functions().Get(callee_function.function_id); + + if (auto builtin_kind = function.builtin_function_kind; builtin_kind != SemIR::BuiltinFunctionKind::None) { HandleBuiltinCall(context, inst_id, builtin_kind, arg_ids); return; @@ -508,8 +508,6 @@ auto HandleInst(FunctionContext& context, SemIR::InstId inst_id, } llvm::CallInst* call; - const auto& function = - context.sem_ir().functions().Get(callee_function.function_id); if (function.virtual_index != -1) { CARBON_CHECK(!args.empty(), "Virtual functions must have at least one parameter");