Skip to content

Commit 4e4d48e

Browse files
authored
Fix several coding style and return value unchecked issues (bytecodealliance#722)
And enable building Windows CI with multi cores
1 parent 3953f81 commit 4e4d48e

File tree

3 files changed

+38
-25
lines changed

3 files changed

+38
-25
lines changed

.github/workflows/windows.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,55 +30,55 @@ jobs:
3030
cd product-mini/platforms/windows
3131
mkdir build && cd build
3232
cmake ..
33-
cmake --build . --config Release
33+
cmake --build . --config Release --parallel 4
3434
cd .. && rm -force -r build
3535
- name: Build iwasm [aot only]
3636
run: |
3737
cd product-mini/platforms/windows
3838
mkdir build && cd build
3939
cmake .. -DWAMR_BUILD_AOT=1 -DWAMR_BUILD_INTERP=0
40-
cmake --build . --config Release
40+
cmake --build . --config Release --parallel 4
4141
cd .. && rm -force -r build
4242
- name: Build iwasm [interp only]
4343
run: |
4444
cd product-mini/platforms/windows
4545
mkdir build && cd build
4646
cmake .. -DWAMR_BUILD_AOT=0
47-
cmake --build . --config Release
47+
cmake --build . --config Release --parallel 4
4848
cd .. && rm -force -r build
4949
- name: Build iwasm [tail call]
5050
run: |
5151
cd product-mini/platforms/windows
5252
mkdir build && cd build
5353
cmake .. -DWAMR_BUILD_TAIL_CALL=1
54-
cmake --build . --config Release
54+
cmake --build . --config Release --parallel 4
5555
cd .. && rm -force -r build
5656
- name: Build iwasm [custom name section]
5757
run: |
5858
cd product-mini/platforms/windows
5959
mkdir build && cd build
6060
cmake .. -DWAMR_BUILD_CUSTOM_NAME_SECTION=1
61-
cmake --build . --config Release
61+
cmake --build . --config Release --parallel 4
6262
cd .. && rm -force -r build
6363
- name: Build iwasm [disable hardware boundary check]
6464
run: |
6565
cd product-mini/platforms/windows
6666
mkdir build && cd build
6767
cmake .. -DWAMR_DISABLE_HW_BOUND_CHECK=1
68-
cmake --build . --config Release
68+
cmake --build . --config Release --parallel 4
6969
cd .. && rm -force -r build
7070
- name: Build iwasm [reference types]
7171
run: |
7272
cd product-mini/platforms/windows
7373
mkdir build && cd build
7474
cmake .. -DWAMR_BUILD_REF_TYPES=1
75-
cmake --build . --config Release
75+
cmake --build . --config Release --parallel 4
7676
cd .. && rm -force -r build
7777
- name: Build iwasm [128-bit SIMD]
7878
run: |
7979
cd product-mini/platforms/windows
8080
mkdir build && cd build
8181
cmake .. -DWAMR_BUILD_SIMD=1
82-
cmake --build . --config Release
82+
cmake --build . --config Release --parallel 4
8383
cd .. && rm -force -r build
8484

core/iwasm/compilation/aot_emit_compare.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
#include "aot_emit_compare.h"
7-
#include "aot_intrinsic.h"
7+
#include "../aot/aot_intrinsic.h"
88

99
static bool
1010
int_cond_to_llvm_op(IntCond cond, LLVMIntPredicate *op)
@@ -158,23 +158,25 @@ aot_compile_op_f32_compare(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
158158
POP_F32(rhs);
159159
POP_F32(lhs);
160160

161-
if (comp_ctx->disable_llvm_intrinsics && aot_intrinsic_check_capability(comp_ctx, "f32_cmp"))
162-
{
161+
if (comp_ctx->disable_llvm_intrinsics
162+
&& aot_intrinsic_check_capability(comp_ctx, "f32_cmp")) {
163163
LLVMTypeRef param_types[3];
164164
LLVMValueRef opcond = LLVMConstInt(I32_TYPE, cond, true);
165165
param_types[0] = I32_TYPE;
166166
param_types[1] = F32_TYPE;
167167
param_types[2] = F32_TYPE;
168-
res = aot_call_llvm_intrinsic(comp_ctx, func_ctx, "f32_cmp", I32_TYPE, param_types, 3, opcond, lhs, rhs);
168+
res = aot_call_llvm_intrinsic(comp_ctx, func_ctx, "f32_cmp", I32_TYPE,
169+
param_types, 3, opcond, lhs, rhs);
170+
if (!res) {
171+
goto fail;
172+
}
169173
res = LLVMBuildIntCast(comp_ctx->builder, res, INT1_TYPE, "bit_cast");
170174
}
171-
else
172-
{
175+
else {
173176
res = LLVMBuildFCmp(comp_ctx->builder, op, lhs, rhs, "f32_cmp");
174177
}
175178

176-
if (!res)
177-
{
179+
if (!res) {
178180
aot_set_last_error("llvm build compare failed.");
179181
return false;
180182
}
@@ -200,23 +202,25 @@ aot_compile_op_f64_compare(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
200202
POP_F64(rhs);
201203
POP_F64(lhs);
202204

203-
if (comp_ctx->disable_llvm_intrinsics && aot_intrinsic_check_capability(comp_ctx, "f64_cmp"))
204-
{
205+
if (comp_ctx->disable_llvm_intrinsics
206+
&& aot_intrinsic_check_capability(comp_ctx, "f64_cmp")) {
205207
LLVMTypeRef param_types[3];
206208
LLVMValueRef opcond = LLVMConstInt(I32_TYPE, cond, true);
207209
param_types[0] = I32_TYPE;
208210
param_types[1] = F64_TYPE;
209211
param_types[2] = F64_TYPE;
210-
res = aot_call_llvm_intrinsic(comp_ctx, func_ctx, "f64_cmp", I32_TYPE, param_types, 3, opcond, lhs, rhs);
212+
res = aot_call_llvm_intrinsic(comp_ctx, func_ctx, "f64_cmp", I32_TYPE,
213+
param_types, 3, opcond, lhs, rhs);
214+
if (!res) {
215+
goto fail;
216+
}
211217
res = LLVMBuildIntCast(comp_ctx->builder, res, INT1_TYPE, "bit_cast");
212218
}
213-
else
214-
{
219+
else {
215220
res = LLVMBuildFCmp(comp_ctx->builder, op, lhs, rhs, "f64_cmp");
216221
}
217222

218-
if (!res)
219-
{
223+
if (!res) {
220224
aot_set_last_error("llvm build compare failed.");
221225
return false;
222226
}

core/iwasm/compilation/aot_emit_conversion.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#include "aot_emit_conversion.h"
77
#include "aot_emit_exception.h"
88
#include "aot_emit_numberic.h"
9-
#include "aot_intrinsic.h"
10-
#include "aot_runtime.h"
9+
#include "../aot/aot_intrinsic.h"
10+
#include "../aot/aot_runtime.h"
1111

1212
static bool
1313
trunc_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
@@ -29,6 +29,9 @@ trunc_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
2929
res = aot_call_llvm_intrinsic(
3030
comp_ctx, func_ctx, src_type == F32_TYPE ? "f32_cmp" : "f64_cmp",
3131
I32_TYPE, param_types, 3, opcond, operand, operand);
32+
if (!res) {
33+
goto fail;
34+
}
3235
res = LLVMBuildIntCast(comp_ctx->builder, res, INT1_TYPE, "bit_cast");
3336
}
3437
else {
@@ -67,6 +70,9 @@ trunc_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
6770
is_less = aot_call_llvm_intrinsic(
6871
comp_ctx, func_ctx, src_type == F32_TYPE ? "f32_cmp" : "f64_cmp",
6972
I32_TYPE, param_types, 3, opcond, operand, min_value);
73+
if (!is_less) {
74+
goto fail;
75+
}
7076
is_less =
7177
LLVMBuildIntCast(comp_ctx->builder, is_less, INT1_TYPE, "bit_cast");
7278
}
@@ -91,6 +97,9 @@ trunc_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
9197
is_greater = aot_call_llvm_intrinsic(
9298
comp_ctx, func_ctx, src_type == F32_TYPE ? "f32_cmp" : "f64_cmp",
9399
I32_TYPE, param_types, 3, opcond, operand, max_value);
100+
if (!is_greater) {
101+
goto fail;
102+
}
94103
is_greater = LLVMBuildIntCast(comp_ctx->builder, is_greater, INT1_TYPE,
95104
"bit_cast");
96105
}

0 commit comments

Comments
 (0)