mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +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:
@@ -16,12 +16,15 @@ namespace Carbon::Lower {
|
||||
|
||||
FunctionContext::FunctionContext(
|
||||
FileContext& file_context, llvm::Function* function,
|
||||
FileContext& specific_file_context, SemIR::SpecificId specific_id,
|
||||
FileContext& specific_file_context,
|
||||
SemIR::FunctionId specific_sem_ir_function_id,
|
||||
SemIR::SpecificId specific_id,
|
||||
SpecificCoalescer::SpecificFunctionFingerprint* function_fingerprint,
|
||||
llvm::DISubprogram* di_subprogram, llvm::raw_ostream* vlog_stream)
|
||||
: file_context_(&file_context),
|
||||
function_(function),
|
||||
specific_file_context_(&specific_file_context),
|
||||
specific_sem_ir_function_id_(specific_sem_ir_function_id),
|
||||
specific_id_(specific_id),
|
||||
builder_(file_context.llvm_context(), llvm::ConstantFolder(),
|
||||
Inserter(file_context.inst_namer())),
|
||||
|
||||
Reference in New Issue
Block a user