mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 16:21:04 +01:00
return 0 from Run when it doesn't specify a return value (#7180)
https://carbon.compiler-explorer.com/z/88K9Kh5Wo shows the program exiting with a garbage value copied from uninitialized memory. This PR modifies `lower` to detect if the function lowered is the entry point and doesn't specify a return type. If so, it emits different LLVM IR to return int32 0, and modifies the lowered function signature to match the int32 return type.
This commit is contained in:
@@ -548,9 +548,9 @@ auto FileContext::BuildFunctionBody(SemIR::FunctionId function_id,
|
||||
|
||||
auto* subprogram = BuildDISubprogram(declaration_function, *function_info);
|
||||
FunctionContext function_lowering(
|
||||
definition_context, function_info->llvm_function, *this, specific_id,
|
||||
coalescer_.InitializeFingerprintForSpecific(specific_id), subprogram,
|
||||
vlog_stream_);
|
||||
definition_context, function_info->llvm_function, *this, function_id,
|
||||
specific_id, coalescer_.InitializeFingerprintForSpecific(specific_id),
|
||||
subprogram, vlog_stream_);
|
||||
|
||||
auto call_param_ids = definition_ir.inst_blocks().GetOrEmpty(
|
||||
definition_function.call_params_id);
|
||||
|
||||
Reference in New Issue
Block a user