Skip to content

Commit d1141f6

Browse files
aot compiler: Allow to control stack boundary check when boundary check is enabled (#3754)
In the AOT compiler, allow the user to control stack boundary check when the boundary check is enabled (e.g. `wamrc --bounds-checks=1`). Now the code logic is: 1. When `--stack-bounds-checks` is not set, it will be the same value as `--bounds-checks`. 2. When `--stack-bounds-checks` is set, it will be the option value no matter what the status of `--bounds-checks` is.
1 parent 20949bd commit d1141f6

3 files changed

Lines changed: 12 additions & 13 deletions

File tree

core/iwasm/compilation/aot_llvm.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2969,12 +2969,12 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
29692969
sizeof(comp_ctx->target_arch));
29702970

29712971
if (option->bounds_checks == 1 || option->bounds_checks == 0) {
2972-
/* Set by user */
2972+
/* Set by the user */
29732973
comp_ctx->enable_bound_check =
29742974
(option->bounds_checks == 1) ? true : false;
29752975
}
29762976
else {
2977-
/* Unset by user, use default value */
2977+
/* Unset by the user, use the default value */
29782978
if (strstr(comp_ctx->target_arch, "64")
29792979
&& !option->is_sgx_platform) {
29802980
comp_ctx->enable_bound_check = false;
@@ -2984,17 +2984,17 @@ aot_create_comp_context(const AOTCompData *comp_data, aot_comp_option_t option)
29842984
}
29852985
}
29862986

2987-
if (comp_ctx->enable_bound_check) {
2988-
/* Always enable stack boundary check if `bounds-checks`
2989-
is enabled */
2990-
comp_ctx->enable_stack_bound_check = true;
2991-
}
2992-
else {
2993-
/* When `bounds-checks` is disabled, we set stack boundary
2994-
check status according to the input option */
2987+
if (option->stack_bounds_checks == 1
2988+
|| option->stack_bounds_checks == 0) {
2989+
/* Set by the user */
29952990
comp_ctx->enable_stack_bound_check =
29962991
(option->stack_bounds_checks == 1) ? true : false;
29972992
}
2993+
else {
2994+
/* Unset by the user, use the default value, it will be the same
2995+
* value as the bound check */
2996+
comp_ctx->enable_stack_bound_check = comp_ctx->enable_bound_check;
2997+
}
29982998

29992999
if ((comp_ctx->enable_stack_bound_check
30003000
|| comp_ctx->enable_stack_estimation)

core/iwasm/interpreter/wasm_interp_classic.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5739,6 +5739,7 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
57395739
/* use memmove when memory64 is enabled since len
57405740
may be larger than UINT32_MAX */
57415741
memmove(mdst, msrc, len);
5742+
(void)dlen;
57425743
#endif
57435744
break;
57445745
}

wamr-compiler/main.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,7 @@ print_help()
142142
printf(" with a runtime without the hardware bounds checks.\n");
143143
printf(" --stack-bounds-checks=1/0 Enable or disable the bounds checks for native stack:\n");
144144
printf(" if the option isn't set, the status is same as `--bounds-check`,\n");
145-
printf(" if the option is set:\n");
146-
printf(" (1) it is always enabled when `--bounds-checks` is enabled,\n");
147-
printf(" (2) else it is enabled/disabled according to the option value\n");
145+
printf(" if the option is set, the status is same as the option value\n");
148146
printf(" --stack-usage=<file> Generate a stack-usage file.\n");
149147
printf(" Similarly to `clang -fstack-usage`.\n");
150148
printf(" --format=<format> Specifies the format of the output file\n");

0 commit comments

Comments
 (0)