Check ValueKind before extracting a constant int value (#2595)

Only when the value kind is LLVMConstantIntValueKind and the value
is not undef and not poison can we extract the value of a constant int.

Fixes #2557 and #2559.
This commit is contained in:
liang.he
2023-09-28 09:15:56 +08:00
committed by GitHub
parent 79b27c1934
commit cd0cec5beb
4 changed files with 25 additions and 18 deletions

View File

@ -363,6 +363,19 @@ check_type_compatible(uint8 src_type, uint8 dst_type)
} \
} while (0)
/* if val is a constant integer and its value is not undef or poison */
static inline bool
LLVMIsEfficientConstInt(LLVMValueRef val)
{
return LLVMIsConstant(val)
&& LLVMGetValueKind(val) == LLVMConstantIntValueKind
&& !LLVMIsUndef(val)
#if LLVM_VERSION_NUMBER >= 12
&& !LLVMIsPoison(addr)
#endif
;
}
bool
aot_compile_wasm(AOTCompContext *comp_ctx);