Skip to content

Commit 0b4cb7f

Browse files
authored
Fix alloca builder creation (#107464)
This was hitting assert with debug version of llvm
1 parent 605c6fd commit 0b4cb7f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/mono/mono/mini/mini-llvm.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2962,7 +2962,10 @@ build_alloca_llvm_type_name (EmitContext *ctx, LLVMTypeRef t, int align, const c
29622962
* Have to place all alloca's at the end of the entry bb, since otherwise they would
29632963
* get executed every time control reaches them.
29642964
*/
2965-
LLVMPositionBuilder (ctx->alloca_builder, get_bb (ctx, ctx->cfg->bb_entry), ctx->last_alloca);
2965+
if (ctx->last_alloca)
2966+
LLVMPositionBuilder (ctx->alloca_builder, get_bb (ctx, ctx->cfg->bb_entry), ctx->last_alloca);
2967+
else
2968+
LLVMPositionBuilderAtEnd (ctx->alloca_builder, get_bb (ctx, ctx->cfg->bb_entry));
29662969

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

0 commit comments

Comments
 (0)