Skip to content

Commit

Permalink
[llvm] Fix spilling of valuetypes to the stack if they are passed by …
Browse files Browse the repository at this point in the history
…addr. (#92658)

The previous code would spill the valuetype when it was passed by addr,
and another bblock could try to read from the unitialized stack location.
  • Loading branch information
vargaz authored Oct 2, 2023
1 parent 215145e commit eae953b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/mono/mono/mini/mini-llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -7812,10 +7812,10 @@ MONO_RESTORE_WARNING
LLVMTypeRef etype = type_to_llvm_type (ctx, t);

if (!addresses [ins->sreg1]) {
addresses [ins->sreg1] = create_address (ctx->module, build_named_alloca (ctx, t, "llvm_outarg_vt"), etype);
g_assert (!addresses [ins->dreg]);
addresses [ins->dreg] = create_address (ctx->module, build_named_alloca (ctx, t, "llvm_outarg_vt"), etype);
g_assert (values [ins->sreg1]);
LLVMBuildStore (builder, convert (ctx, values [ins->sreg1], etype), addresses [ins->sreg1]->value);
addresses [ins->dreg] = addresses [ins->sreg1];
LLVMBuildStore (builder, convert (ctx, values [ins->sreg1], etype), addresses [ins->dreg]->value);
} else if (ainfo->storage == LLVMArgVtypeAddr || values [ins->sreg1] == addresses [ins->sreg1]->value) {
/* LLVMArgVtypeByRef/LLVMArgVtypeAddr, have to make a copy */
addresses [ins->dreg] = build_alloca_address (ctx, t);
Expand Down

0 comments on commit eae953b

Please sign in to comment.