Skip to content

Commit 66e6e1f

Browse files
authored
Clear more compile warnings reported by -Wshadow flag (#899)
1 parent 4258b24 commit 66e6e1f

File tree

6 files changed

+46
-46
lines changed

6 files changed

+46
-46
lines changed

core/iwasm/aot/aot_runtime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1403,7 +1403,7 @@ aot_call_function(WASMExecEnv *exec_env, AOTFunctionInstance *function,
14031403
bool ret;
14041404

14051405
if (argc < func_type->param_cell_num) {
1406-
char buf[128];
1406+
char buf[108];
14071407
snprintf(buf, sizeof(buf),
14081408
"invalid argument count %u, must be no smaller than %u", argc,
14091409
func_type->param_cell_num);

core/iwasm/compilation/aot_emit_control.c

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -74,41 +74,41 @@ format_block_name(char *name, uint32 name_size, uint32 block_index,
7474
#define SET_BUILDER_POS(llvm_block) \
7575
LLVMPositionBuilderAtEnd(comp_ctx->builder, llvm_block)
7676

77-
#define CREATE_RESULT_VALUE_PHIS(block) \
78-
do { \
79-
if (block->result_count && !block->result_phis) { \
80-
uint32 i; \
81-
uint64 size; \
82-
LLVMBasicBlockRef block_curr = CURR_BLOCK(); \
83-
/* Allocate memory */ \
84-
size = sizeof(LLVMValueRef) * (uint64)block->result_count; \
85-
if (size >= UINT32_MAX \
86-
|| !(block->result_phis = \
87-
wasm_runtime_malloc((uint32)size))) { \
88-
aot_set_last_error("allocate memory failed."); \
89-
goto fail; \
90-
} \
91-
SET_BUILDER_POS(block->llvm_end_block); \
92-
for (i = 0; i < block->result_count; i++) { \
93-
if (!(block->result_phis[i] = LLVMBuildPhi( \
94-
comp_ctx->builder, \
95-
TO_LLVM_TYPE(block->result_types[i]), "phi"))) { \
96-
aot_set_last_error("llvm build phi failed."); \
97-
goto fail; \
98-
} \
99-
} \
100-
SET_BUILDER_POS(block_curr); \
101-
} \
77+
#define CREATE_RESULT_VALUE_PHIS(block) \
78+
do { \
79+
if (block->result_count && !block->result_phis) { \
80+
uint32 _i; \
81+
uint64 _size; \
82+
LLVMBasicBlockRef _block_curr = CURR_BLOCK(); \
83+
/* Allocate memory */ \
84+
_size = sizeof(LLVMValueRef) * (uint64)block->result_count; \
85+
if (_size >= UINT32_MAX \
86+
|| !(block->result_phis = \
87+
wasm_runtime_malloc((uint32)_size))) { \
88+
aot_set_last_error("allocate memory failed."); \
89+
goto fail; \
90+
} \
91+
SET_BUILDER_POS(block->llvm_end_block); \
92+
for (_i = 0; _i < block->result_count; _i++) { \
93+
if (!(block->result_phis[_i] = LLVMBuildPhi( \
94+
comp_ctx->builder, \
95+
TO_LLVM_TYPE(block->result_types[_i]), "phi"))) { \
96+
aot_set_last_error("llvm build phi failed."); \
97+
goto fail; \
98+
} \
99+
} \
100+
SET_BUILDER_POS(_block_curr); \
101+
} \
102102
} while (0)
103103

104104
#define ADD_TO_RESULT_PHIS(block, value, idx) \
105105
do { \
106-
LLVMBasicBlockRef block_curr = CURR_BLOCK(); \
106+
LLVMBasicBlockRef _block_curr = CURR_BLOCK(); \
107107
LLVMTypeRef phi_ty = LLVMTypeOf(block->result_phis[idx]); \
108108
LLVMTypeRef value_ty = LLVMTypeOf(value); \
109109
bh_assert(LLVMGetTypeKind(phi_ty) == LLVMGetTypeKind(value_ty)); \
110110
bh_assert(LLVMGetTypeContext(phi_ty) == LLVMGetTypeContext(value_ty)); \
111-
LLVMAddIncoming(block->result_phis[idx], &value, &block_curr, 1); \
111+
LLVMAddIncoming(block->result_phis[idx], &value, &_block_curr, 1); \
112112
(void)phi_ty; \
113113
(void)value_ty; \
114114
} while (0)
@@ -122,10 +122,10 @@ format_block_name(char *name, uint32 name_size, uint32 block_index,
122122
} \
123123
} while (0)
124124

125-
#define ADD_TO_PARAM_PHIS(block, value, idx) \
126-
do { \
127-
LLVMBasicBlockRef block_curr = CURR_BLOCK(); \
128-
LLVMAddIncoming(block->param_phis[idx], &value, &block_curr, 1); \
125+
#define ADD_TO_PARAM_PHIS(block, value, idx) \
126+
do { \
127+
LLVMBasicBlockRef _block_curr = CURR_BLOCK(); \
128+
LLVMAddIncoming(block->param_phis[idx], &value, &_block_curr, 1); \
129129
} while (0)
130130

131131
static LLVMBasicBlockRef

core/iwasm/compilation/aot_emit_memory.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
8585
LLVMValueRef mem_base_addr, mem_check_bound;
8686
LLVMBasicBlockRef block_curr = LLVMGetInsertBlock(comp_ctx->builder);
8787
LLVMBasicBlockRef check_succ;
88-
AOTValue *aot_value;
88+
AOTValue *aot_value_top;
8989
uint32 local_idx_of_aot_value = 0;
9090
bool is_target_64bit, is_local_of_aot_value = false;
9191
#if WASM_ENABLE_SHARED_MEMORY != 0
@@ -114,13 +114,13 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
114114
}
115115
}
116116

117-
aot_value =
117+
aot_value_top =
118118
func_ctx->block_stack.block_list_end->value_stack.value_list_end;
119-
if (aot_value) {
120-
/* aot_value is freed in the following POP_I32(addr),
119+
if (aot_value_top) {
120+
/* aot_value_top is freed in the following POP_I32(addr),
121121
so save its fields here for further use */
122-
is_local_of_aot_value = aot_value->is_local;
123-
local_idx_of_aot_value = aot_value->local_idx;
122+
is_local_of_aot_value = aot_value_top->is_local;
123+
local_idx_of_aot_value = aot_value_top->local_idx;
124124
}
125125

126126
POP_I32(addr);

core/iwasm/compilation/aot_emit_variable.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ aot_compile_op_get_local(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
3232
{
3333
char name[32];
3434
LLVMValueRef value;
35-
AOTValue *aot_value;
35+
AOTValue *aot_value_top;
3636

3737
CHECK_LOCAL(local_idx);
3838

@@ -45,10 +45,10 @@ aot_compile_op_get_local(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
4545

4646
PUSH(value, get_local_type(func_ctx, local_idx));
4747

48-
aot_value =
48+
aot_value_top =
4949
func_ctx->block_stack.block_list_end->value_stack.value_list_end;
50-
aot_value->is_local = true;
51-
aot_value->local_idx = local_idx;
50+
aot_value_top->is_local = true;
51+
aot_value_top->local_idx = local_idx;
5252
return true;
5353

5454
fail:

core/iwasm/compilation/aot_llvm.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,7 +1813,7 @@ aot_create_comp_context(AOTCompData *comp_data, aot_comp_option_t option)
18131813

18141814
if (option->enable_simd) {
18151815
char *tmp;
1816-
bool ret;
1816+
bool check_simd_ret;
18171817

18181818
comp_ctx->enable_simd = true;
18191819

@@ -1822,9 +1822,10 @@ aot_create_comp_context(AOTCompData *comp_data, aot_comp_option_t option)
18221822
goto fail;
18231823
}
18241824

1825-
ret = aot_check_simd_compatibility(comp_ctx->target_arch, tmp);
1825+
check_simd_ret =
1826+
aot_check_simd_compatibility(comp_ctx->target_arch, tmp);
18261827
LLVMDisposeMessage(tmp);
1827-
if (!ret) {
1828+
if (!check_simd_ret) {
18281829
aot_set_last_error("SIMD compatibility check failed, "
18291830
"try adding --cpu=<cpu> to specify a cpu "
18301831
"or adding --disable-simd to disable SIMD");

core/iwasm/interpreter/wasm_loader.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,6 @@ load_init_expr(const uint8 **p_buf, const uint8 *buf_end,
456456
#if (WASM_ENABLE_WAMR_COMPILER != 0) || (WASM_ENABLE_JIT != 0)
457457
case INIT_EXPR_TYPE_V128_CONST:
458458
{
459-
uint8 flag;
460459
uint64 high, low;
461460

462461
if (type != VALUE_TYPE_V128)

0 commit comments

Comments
 (0)