mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-08 20:56:13 +00:00
Fix potential issue in aot compiler when translating block opcodes (#2622)
The LLVM zext IR may be inserted after the terminator of a basic block when popping the arguments of a wasm block. Change to insert the zext IR before the terminator of the basic block to resolve the issue. Reported in #2620.
This commit is contained in:
parent
7c22bde8dc
commit
059fbfc252
|
@ -281,7 +281,7 @@ push_aot_block_to_stack_and_pass_params(AOTCompContext *comp_ctx,
|
||||||
AOTBlock *block)
|
AOTBlock *block)
|
||||||
{
|
{
|
||||||
uint32 i, param_index;
|
uint32 i, param_index;
|
||||||
LLVMValueRef value;
|
LLVMValueRef value, br_inst;
|
||||||
uint64 size;
|
uint64 size;
|
||||||
char name[32];
|
char name[32];
|
||||||
LLVMBasicBlockRef block_curr = CURR_BLOCK();
|
LLVMBasicBlockRef block_curr = CURR_BLOCK();
|
||||||
|
@ -329,7 +329,14 @@ push_aot_block_to_stack_and_pass_params(AOTCompContext *comp_ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SET_BUILDER_POS(block_curr);
|
|
||||||
|
/* At this point, the branch instruction was already built to jump to
|
||||||
|
* the new BB, to avoid generating zext instruction from the popped
|
||||||
|
* operand that would come after branch instruction, we should position
|
||||||
|
* the builder before the last branch instruction */
|
||||||
|
br_inst = LLVMGetLastInstruction(block_curr);
|
||||||
|
bh_assert(LLVMGetInstructionOpcode(br_inst) == LLVMBr);
|
||||||
|
LLVMPositionBuilderBefore(comp_ctx->builder, br_inst);
|
||||||
|
|
||||||
/* Pop param values from current block's
|
/* Pop param values from current block's
|
||||||
* value stack and add to param phis.
|
* value stack and add to param phis.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user