aot compiler: Fix handle next reachable if block (#2793)

The popped reachable block may be if block whose else branch hasn't been
translated, and should push the params for the else block if there are.

And use LLVMDisposeMessage to free memory allocated in is_win_platform.
This commit is contained in:
Wenyong Huang 2023-11-20 17:14:10 +08:00 committed by GitHub
parent a57e70016a
commit 103cb89593
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 3 deletions

View File

@ -202,6 +202,9 @@ handle_next_reachable_block(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
*p_frame_ip = block->wasm_code_else + 1;
/* Push back the block */
aot_block_stack_push(&func_ctx->block_stack, block);
/* Recover parameters of else branch */
for (i = 0; i < block->param_count; i++)
PUSH(block->else_param_phis[i], block->param_types[i]);
return true;
}
else if (block->llvm_end_block) {
@ -221,6 +224,19 @@ handle_next_reachable_block(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
return true;
}
if (block->label_type == LABEL_TYPE_IF && block->llvm_else_block
&& !block->skip_wasm_code_else
&& *p_frame_ip <= block->wasm_code_else) {
/* Clear value stack and start to translate else branch */
aot_value_stack_destroy(&block->value_stack);
/* Recover parameters of else branch */
for (i = 0; i < block->param_count; i++)
PUSH(block->else_param_phis[i], block->param_types[i]);
SET_BUILDER_POS(block->llvm_else_block);
*p_frame_ip = block->wasm_code_else + 1;
return true;
}
*p_frame_ip = block->wasm_code_end + 1;
SET_BUILDER_POS(block->llvm_end_block);

View File

@ -22,11 +22,14 @@ static bool
is_win_platform(AOTCompContext *comp_ctx)
{
char *triple = LLVMGetTargetMachineTriple(comp_ctx->target_machine);
bool ret;
bh_assert(triple);
if (strstr(triple, "win32") || strstr(triple, "win"))
return true;
return false;
ret = (strstr(triple, "win32") || strstr(triple, "win")) ? true : false;
LLVMDisposeMessage(triple);
return ret;
}
static bool