Several source files in CMSIS-NN use GCC-specific optimization hints that are not properly guarded against non-GCC compilers. Building with Clang/LLVM Embedded Toolchain for Arm produces warnings, and one case also affects IAR.
Case 1 - attribute((optimize(...))) missing Clang and IAR guards
|
#if !defined(__ARMCC_VERSION) |
Problem:
The guard only excludes Arm Compiler (__ARMCC_VERSION). Clang
(clang) and IAR (ICCARM) are not excluded, so both compilers
receive the GCC-specific attribute.
Compilers affected:
- Clang/LLVM Embedded Toolchain for Arm 19.1.5 - warning:
warning: unknown attribute 'optimize' ignored [-Wunknown-attributes]
- IAR C/C++ Compiler for Arm 9.70.1 - warning:
Warning[Pe1097]: unknown attribute 'optimize'
Suggested fix:
#if !defined(__ARMCC_VERSION) && !defined(__ICCARM__) && !defined(__clang__)
__attribute__((optimize("no-unroll-loops")))
#endif
Case 2 - #pragma GCC optimize(...) missing Clang guard
Files:
|
#if !defined(ARM_MATH_MVEI) && defined(ARM_MATH_DSP) && !defined(__ARMCC_VERSION) && !defined(__ICCARM__) |
|
#if !defined(ARM_MATH_MVEI) && defined(ARM_MATH_DSP) && !defined(__ARMCC_VERSION) && !defined(__ICCARM__) |
Problem:
The guard correctly excludes ARMCC and IAR, but does not exclude Clang,
which does not implement #pragma GCC optimize.
Compilers affected:
- Clang/LLVM Embedded Toolchain for Arm 19.1.5 - warning:
warning: unknown pragma ignored [-Wunknown-pragmas]
Suggested fix:
#if !defined(ARM_MATH_MVEI) && defined(ARM_MATH_DSP) && !defined(__ARMCC_VERSION) && !defined(__ICCARM__) && !defined(__clang__)
#pragma GCC optimize("unroll-loops")
#endif
Environment
- Toolchain: LLVM Embedded Toolchain for Arm 19.1.5, IAR C/C++ Compiler for Arm: 9.70.1
- Target: Cortex-M33, Cortex-M55
Several source files in CMSIS-NN use GCC-specific optimization hints that are not properly guarded against non-GCC compilers. Building with Clang/LLVM Embedded Toolchain for Arm produces warnings, and one case also affects IAR.
Case 1 - attribute((optimize(...))) missing Clang and IAR guards
CMSIS-NN/Source/ConvolutionFunctions/arm_depthwise_conv_s8.c
Line 43 in 22080c6
Problem:
The guard only excludes Arm Compiler (__ARMCC_VERSION). Clang
(clang) and IAR (ICCARM) are not excluded, so both compilers
receive the GCC-specific attribute.
Compilers affected:
Suggested fix:
Case 2 - #pragma GCC optimize(...) missing Clang guard
Files:
CMSIS-NN/Source/NNSupportFunctions/arm_nn_vec_mat_mult_t_s8.c
Line 55 in 22080c6
CMSIS-NN/Source/NNSupportFunctions/arm_nn_vec_mat_mult_t_per_ch_s8.c
Line 55 in 22080c6
Problem:
The guard correctly excludes ARMCC and IAR, but does not exclude Clang,
which does not implement #pragma GCC optimize.
Compilers affected:
Suggested fix:
Environment