Skip to content

Commit a426b7d

Browse files
committed
remove non-const array initializer
1 parent 4500f7b commit a426b7d

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

core/iwasm/compilation/aot_emit_function.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,15 @@ aot_emit_call_target_hint(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
130130
hint->used = true;
131131
struct WASMCompilationHintCallTargets *ct_hint =
132132
(struct WASMCompilationHintCallTargets *)hint;
133-
unsigned md_node_cnt = ct_hint->target_count * 2 + 3;
134-
LLVMMetadataRef md_nodes[md_node_cnt];
133+
134+
const unsigned md_node_cnt = ct_hint->target_count * 2 + 3;
135+
LLVMMetadataRef *md_nodes =
136+
wasm_runtime_malloc(md_node_cnt * sizeof(LLVMMetadataRef));
137+
if (!md_nodes) {
138+
aot_set_last_error("allocate memory failed.");
139+
return;
140+
}
141+
135142
md_nodes[0] =
136143
LLVMMDStringInContext2(comp_ctx->context, "VP", strlen("VP"));
137144
md_nodes[1] = LLVMValueAsMetadata(I32_CONST(0));
@@ -159,6 +166,7 @@ aot_emit_call_target_hint(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
159166
LLVMValueRef meta_data_as_value =
160167
LLVMMetadataAsValue(comp_ctx->context, meta_data);
161168
LLVMSetMetadata(call_instr, 2, meta_data_as_value);
169+
wasm_runtime_free(md_nodes);
162170
}
163171
}
164172
#endif

0 commit comments

Comments
 (0)