Skip to content

Commit

Permalink
Fix alloca builder creation (#107464)
Browse files Browse the repository at this point in the history
This was hitting assert with debug version of llvm
  • Loading branch information
radekdoulik committed Sep 11, 2024
1 parent 605c6fd commit 0b4cb7f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/mono/mono/mini/mini-llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2962,7 +2962,10 @@ build_alloca_llvm_type_name (EmitContext *ctx, LLVMTypeRef t, int align, const c
* Have to place all alloca's at the end of the entry bb, since otherwise they would
* get executed every time control reaches them.
*/
LLVMPositionBuilder (ctx->alloca_builder, get_bb (ctx, ctx->cfg->bb_entry), ctx->last_alloca);
if (ctx->last_alloca)
LLVMPositionBuilder (ctx->alloca_builder, get_bb (ctx, ctx->cfg->bb_entry), ctx->last_alloca);
else
LLVMPositionBuilderAtEnd (ctx->alloca_builder, get_bb (ctx, ctx->cfg->bb_entry));

ctx->last_alloca = mono_llvm_build_alloca (ctx->alloca_builder, t, NULL, align, name);
return ctx->last_alloca;
Expand Down

0 comments on commit 0b4cb7f

Please sign in to comment.