mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-11 20:21:11 +00:00
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:
parent
a57e70016a
commit
103cb89593
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user