Skip to content

[err]Compiling cmsis dsp failed when using -O3. #646

@bshaokang

Description

@bshaokang

i found that the problem was caused by the compilation option -o3.
Compiling cmsis dsp failed when using -O3.
Compiling cmsis dsp succeeded when not using -O3.
Is this a bug?

bsk@mcshyucs0008:~/clang_test$ clang-18 -c -Wstrict-prototypes -Wno-attributes -Wno-unknown-pragmas -Oz \
-fno-strict-aliasing -fomit-frame-pointer -fno-builtin -fshort-enums -fno-common -Wall -Wshadow -Wundef \ 
-ffunction-sections -fdata-sections -target armv8.1m.main_hard_fp.cfg -march=armv8.1-m.main+mve \ 
-mtune=cortex-m85 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -Wa,-mthumb -Wa,-mimplicit-it=always \ 
--target=arm-none-eabi  -isystem ~/clang_test/mcu_common/nuttx/include -isystem \
~/clang_test/mcu_common/nuttx/include/newlib -D__NuttX__ -DNDEBUG -DXR_VERSION_FPGA \
-pipe -Werror -g -I~/clang_test/contexthub/../platform/tuling3 \
-I~/clang_test/contexthub/../platform/tuling3/fpgdafen/contexthub/../platform/common/pmu/include/tuling3/fpga \
-I~/clang_test/contexthub/../platform/common/pmu/include/tuling3 \
-I~/clang_test/contexthub/../platform/common/clk/include/tuling3 \
-I~/clang_test/contexthub/chips/mcu/cortex-m85/include \
-I~/clang_test/mcu_common/nuttx/../vendor/contexthub/sensor_drivers/include \
-I~/clang_test/contexthub/cmsis/CMSIS/CMSIS_5-5.9.0/Device/ARM/ARMCM85/Include \
-I~/clang_test/contexthub/cmsis/CMSIS/CMSIS_5-5.9.0/CMSIS/Core/Include \
-I~/clang_test/contexthub/cmsis/CMSIS/CMSIS-DSP-1.15.0/Include \
-I~/clang_test/contexthub/cmsis/CMSIS/CMSIS-NN-4.1.0/Include \
-I~/clang_test/contexthub/securec/include -DSECUREC_ENABLE_FSCANF=0 \
-DSECUREC_ENABLE_VFSCANF=0 -DSECUREC_ENABLE_WCHAR_FUNC=0 \
-DSECUREC_HAVE_WCHART=0 -DSECUREC_ENABLE_SPRINTF_FLOAT=0 \
-DSECUREC_HAVE_WCTOMB=0 -DSECUREC_IN_KERNEL=0 \
-I~/clang_test/contexthub/chips/include -DTODO_REG=0 \
-I ~/clang_test/mcu_common/apps/vendor/contexthub/cmsis/CMSIS/CMSIS-DSP-1.15.0/Include \
-I ~/clang_test/mcu_common/apps/vendor/contexthub/cmsis/CMSIS/CMSIS_5-5.9.0/CMSIS/Core/Include/ \
-I ~/clang_test/mcu_common/apps/include \
-I dafen/open-source/cmsis/CMSIS/CMSIS-DSP-1.15.0/PrivateInclude \
-I dafen/open-source/cmsis/CMSIS_5-5.9.0/CMSIS/DSP/Include/ \
-I dafen/open-source/cmsis/CMSIS_5-5.9.0/CMSIS/Core/Include/ \
-Wno-shadow -flax-vector-conversions \
**-O3** \
dafen/open-source/cmsis/CMSIS-DSP-1.15.0/Source/SupportFunctions/arm_float_to_f16.c -o bskarm_float_to_f16.o \
**-v**
clang version 18.1.3
Target: arm-none-unknown-eabi
Thread model: posix
InstalledDir: ~/clang_test/open-source/clang_for_arm/clang18/bin
 (in-process)
 "~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18" -cc1 \
-triple thumbv8.1m.main-none-unknown-eabihf -emit-obj -mllvm -arm-implicit-it=always \
-disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names \
-main-file-name arm_float_to_f16.c -mrelocation-model static -mframe-pointer=none -relaxed-aliasing \
-fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -nostdsysteminc \
-target-cpu generic -target-feature +vfp2 -target-feature +vfp2sp -target-feature -vfp3 -target-feature +vfp3d16 \
-target-feature +vfp3d16sp -target-feature -vfp3sp -target-feature +fp16 \
-target-feature -vfp4 -target-feature +vfp4d16 -target-feature +vfp4d16sp \
-target-feature -vfp4sp -target-feature -fp-armv8 -target-feature +fp-armv8d16 \
-target-feature +fp-armv8d16sp -target-feature -fp-armv8sp -target-feature -fullfp16 \
-target-feature +fp64 -target-feature -d32 -target-feature -neon -target-feature \
-sha2 -target-feature -aes -target-feature +dsp -target-feature +mve -target-feature \
-fp16fml -target-feature +strict-align -target-abi aapcs -mfloat-abi hard -Wunaligned-access \
-debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb \
-fdebug-compilation-dir=/home/bsk/kasan_test -v -ffunction-sections -fdata-sections \
-fcoverage-compilation-dir=/home/bsk/kasan_test -resource-dir \
~/clang_test/open-source/clang_for_arm/clang18/lib/clang/18 -isystem ~/clang_test/mcu_common/nuttx/include\
 -isystem ~/clang_test/mcu_common/nuttx/include/newlib -D __NuttX__ -D \
NDEBUG -D XR_VERSION_FPGA -I ~/clang_test/contexthub/../platform/tuling3 \
-I ~/clang_test/contexthub/../platform/tuling3/fpgdafen/contexthub/../platform/common/pmu/include/tuling3/fpga \
-I ~/clang_test/contexthub/../platform/common/pmu/include/tuling3 \
-I ~/clang_test/contexthub/../platform/common/clk/include/tuling3 \
-I ~/clang_test/contexthub/chips/mcu/cortex-m85/include \
-I ~/clang_test/mcu_common/nuttx/../vendor/contexthub/sensor_drivers/include \
-I ~/clang_test/contexthub/cmsis/CMSIS/CMSIS_5-5.9.0/Device/ARM/ARMCM85/Include \
-I ~/clang_test/contexthub/cmsis/CMSIS/CMSIS_5-5.9.0/CMSIS/Core/Include \
-I ~/clang_test/contexthub/cmsis/CMSIS/CMSIS-DSP-1.15.0/Include \
-I ~/clang_test/contexthub/cmsis/CMSIS/CMSIS-NN-4.1.0/Include \
-I ~/clang_test/contexthub/securec/include -D SECUREC_ENABLE_FSCANF=0 \
-D SECUREC_ENABLE_VFSCANF=0 -D SECUREC_ENABLE_WCHAR_FUNC=0 -D SECUREC_HAVE_WCHART=0 -D SECUREC_ENABLE_SPRINTF_FLOAT=0 -D SECUREC_HAVE_WCTOMB=0 -D SECUREC_IN_KERNEL=0 -I ~/clang_test/contexthub/chips/include -D TODO_REG=0 \
-I ~/clang_test/mcu_common/apps/vendor/contexthub/cmsis/CMSIS/CMSIS-DSP-1.15.0/Include \
-I ~/clang_test/mcu_common/apps/vendor/contexthub/cmsis/CMSIS/CMSIS_5-5.9.0/CMSIS/Core/Include/ \
-I ~/clang_test/mcu_common/apps/include -I dafen//open-source/cmsis/CMSIS/CMSIS-DSP-1.15.0/PrivateInclude \
-I dafen//open-source/cmsis/CMSIS_5-5.9.0/CMSIS/DSP/Include/ \
-I dafen//open-source/cmsis/CMSIS_5-5.9.0/CMSIS/Core/Include/ \
-internal-isystem ~/clang_test/open-source/clang_for_arm/clang18/lib/clang/18/include -internal-isystem \
~/clang_test/open-source/clang_for_arm/clang18/bin/../lib/clang-runtimes/arm-none-eabi/armv8m.main_hard_fp_exn_rtti/include \
**-O3** \
-Wstrict-prototypes -Wno-attributes -Wno-unknown-pragmas \
-Wall -Wshadow -Wundef -Werror -Wno-shadow -ferror-limit 19 -flax-vector-conversions=integer \
-fno-builtin -fshort-enums -fno-signed-char -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf \
-fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 \
-o bskarm_float_to_f16.o -x c dafen//open-source/cmsis/CMSIS-DSP-1.15.0/Source/SupportFunctions/arm_float_to_f16.c \
clang -cc1 version 18.1.3 based upon LLVM 18.1.3 default target aarch64-linux-gnu
ignoring nonexistent directory "~/clang_test/contexthub/../platform/tuling3/fpgdafen/contexthub/../platform/common/pmu/include/tuling3/fpga"
ignoring nonexistent directory "~/clang_test/mcu_common/nuttx/../vendor/contexthub/sensor_drivers/include"
ignoring nonexistent directory "~/clang_test/contexthub/cmsis/CMSIS/CMSIS_5-5.9.0/Device/ARM/ARMCM85/Include"
ignoring nonexistent directory "~/clang_test/contexthub/cmsis/CMSIS/CMSIS_5-5.9.0/CMSIS/Core/Include"
ignoring nonexistent directory "~/clang_test/contexthub/cmsis/CMSIS/CMSIS-DSP-1.15.0/Include"
ignoring nonexistent directory "~/clang_test/contexthub/cmsis/CMSIS/CMSIS-NN-4.1.0/Include"
ignoring nonexistent directory "~/clang_test/mcu_common/apps/vendor/contexthub/cmsis/CMSIS/CMSIS-DSP-1.15.0/Include"
ignoring nonexistent directory "~/clang_test/mcu_common/apps/vendor/contexthub/cmsis/CMSIS/CMSIS_5-5.9.0/CMSIS/Core/Include/"
ignoring nonexistent directory "open-source/cmsis/CMSIS/CMSIS-DSP-1.15.0/PrivateInclude"
ignoring nonexistent directory "~/clang_test/mcu_common/nuttx/include/newlib"
ignoring duplicate directory "~/clang_test/open-source/clang_for_arm/clang18/lib/clang/18/include"
#include "..." search starts here:
#include <...> search starts here:
 ~/clang_test/contexthub/../platform/tuling3
 ~/clang_test/contexthub/../platform/common/pmu/include/tuling3
 ~/clang_test/contexthub/../platform/common/clk/include/tuling3
 ~/clang_test/contexthub/chips/mcu/cortex-m85/include
 ~/clang_test/contexthub/securec/include
 ~/clang_test/contexthub/chips/include
 ~/clang_test/mcu_common/apps/include
 dafen//open-source/cmsis/CMSIS_5-5.9.0/CMSIS/DSP/Include
 dafen//open-source/cmsis/CMSIS_5-5.9.0/CMSIS/Core/Include
 ~/clang_test/mcu_common/nuttx/include
 ~/clang_test/open-source/clang_for_arm/clang18/lib/clang/18/include
 ~/clang_test/open-source/clang_for_arm/clang18/bin/../lib/clang-runtimes/arm-none-eabi/armv8m.main_hard_fp_exn_rtti/include
End of search list.
fatal error: error in backend: Cannot select: 0x8883b60: v8f16 = ARMISD::VCVTN undef:v8f16, 0x8883150, Constant:i32<0>, dafen//open-source/cmsis/CMSIS-DSP-1.15.0/Source/SupportFunctions/arm_float_to_f16.c:117:17
  0x88830e0: v8f16 = undef
  0x8883150: v4f32,i32,ch = load<(load (s128) from %ir.29, align 4, !alias.scope !37), <post-inc>> 0x83a3ec0, 0x8883850, Constant:i32<16>, dafen//open-source/cmsis/CMSIS-DSP-1.15.0/Source/SupportFunctions/arm_float_to_f16.c:117:31
    0x8883850: i32,ch = CopyFromReg 0x83a3ec0, Register:i32 %6, dafen//open-source/cmsis/CMSIS-DSP-1.15.0/Source/SupportFunctions/arm_float_to_f16.c:117:31
      0x8883770: i32 = Register %6
    0x8883930: i32 = Constant<16>
  0x8882e40: i32 = Constant<0>
In function: arm_float_to_f16
PLEASE submit a bug report to https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/issues and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang-18 -c -Wstrict-prototypes -Wno-attributes -Wno-unknown-pragmas -Oz -fno-strict-aliasing -fomit-frame-pointer -fno-builtin -fshort-enums -fno-common -Wall -Wshadow -Wundef -ffunction-sections -fdata-sections -target armv8.1m.main_hard_fp.cfg -march=armv8.1-m.main+mve -mtune=cortex-m85 -mfpu=fpv5-d16 -mfloat-abi=hard -mthumb -Wa,-mthumb -Wa,-mimplicit-it=always --target=arm-none-eabi -isystem ~/clang_test/mcu_common/nuttx/include -isystem ~/clang_test/mcu_common/nuttx/include/newlib -D__NuttX__ -DNDEBUG -DXR_VERSION_FPGA -pipe -Werror -g -I~/clang_test/contexthub/../platform/tuling3 -I~/clang_test/contexthub/../platform/tuling3/fpgdafen/contexthub/../platform/common/pmu/include/tuling3/fpga -I~/clang_test/contexthub/../platform/common/pmu/include/tuling3 -I~/clang_test/contexthub/../platform/common/clk/include/tuling3 -I~/clang_test/contexthub/chips/mcu/cortex-m85/include -I~/clang_test/mcu_common/nuttx/../vendor/contexthub/sensor_drivers/include -I~/clang_test/contexthub/cmsis/CMSIS/CMSIS_5-5.9.0/Device/ARM/ARMCM85/Include -I~/clang_test/contexthub/cmsis/CMSIS/CMSIS_5-5.9.0/CMSIS/Core/Include -I~/clang_test/contexthub/cmsis/CMSIS/CMSIS-DSP-1.15.0/Include -I~/clang_test/contexthub/cmsis/CMSIS/CMSIS-NN-4.1.0/Include -I~/clang_test/contexthub/securec/include -DSECUREC_ENABLE_FSCANF=0 -DSECUREC_ENABLE_VFSCANF=0 -DSECUREC_ENABLE_WCHAR_FUNC=0 -DSECUREC_HAVE_WCHART=0 -DSECUREC_ENABLE_SPRINTF_FLOAT=0 -DSECUREC_HAVE_WCTOMB=0 -DSECUREC_IN_KERNEL=0 -I~/clang_test/contexthub/chips/include -DTODO_REG=0 -I ~/clang_test/mcu_common/apps/vendor/contexthub/cmsis/CMSIS/CMSIS-DSP-1.15.0/Include -I ~/clang_test/mcu_common/apps/vendor/contexthub/cmsis/CMSIS/CMSIS_5-5.9.0/CMSIS/Core/Include/ -I ~/clang_test/mcu_common/apps/include -I dafen//open-source/cmsis/CMSIS/CMSIS-DSP-1.15.0/PrivateInclude -I dafen//open-source/cmsis/CMSIS_5-5.9.0/CMSIS/DSP/Include/ -I dafen//open-source/cmsis/CMSIS_5-5.9.0/CMSIS/Core/Include/ -Wno-shadow -flax-vector-conversions -O3 dafen//open-source/cmsis/CMSIS-DSP-1.15.0/Source/SupportFunctions/arm_float_to_f16.c -o bskarm_float_to_f16.o -v
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'dafen//open-source/cmsis/CMSIS-DSP-1.15.0/Source/SupportFunctions/arm_float_to_f16.c'.
4.      Running pass 'ARM Instruction Selection' on function '@arm_float_to_f16'
 #0 0x0000000001efc018 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x1efc018)
 #1 0x0000000001efa294 llvm::sys::CleanupOnSignal(unsigned long) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x1efa294)
 #2 0x0000000001e53d83 llvm::CrashRecoveryContext::HandleExit(int) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x1e53d83)
 #3 0x0000000001ef3c9e llvm::sys::Process::Exit(int, bool) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x1ef3c9e)
 #4 0x0000000000ac64ed (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0xac64ed)
 #5 0x0000000001e5b775 llvm::report_fatal_error(llvm::Twine const&, bool) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x1e5b775)
 #6 0x0000000002eefaa1 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x2eefaa1)
 #7 0x0000000002ef3882 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x2ef3882)
 #8 0x0000000000f26cc7 (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0xf26cc7)
 #9 0x0000000002eecb16 llvm::SelectionDAGISel::DoInstructionSelection() (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x2eecb16)
#10 0x0000000002efa51c llvm::SelectionDAGISel::CodeGenAndEmitDAG() (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x2efa51c)
#11 0x0000000002efce76 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x2efce76)
#12 0x0000000002eff706 (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x2eff706)
#13 0x0000000000f2fd24 (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0xf2fd24)
#14 0x000000000147a000 (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x147a000)
#15 0x00000000019e2608 llvm::FPPassManager::runOnFunction(llvm::Function&) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x19e2608)
#16 0x00000000019e277c llvm::FPPassManager::runOnModule(llvm::Module&) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x19e277c)
#17 0x00000000019e30ee llvm::legacy::PassManagerImpl::run(llvm::Module&) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x19e30ee)
#18 0x0000000002140cf3 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x2140cf3)
#19 0x00000000026c9b69 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x26c9b69)
#20 0x0000000003f821a9 clang::ParseAST(clang::Sema&, bool, bool) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x3f821a9)
#21 0x000000000293b179 clang::FrontendAction::Execute() (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x293b179)
#22 0x00000000028be85b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x28be85b)
#23 0x00000000029f6063 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x29f6063)
#24 0x0000000000ac81ce cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0xac81ce)
#25 0x0000000000abfce8 _start (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0xabfce8)
#26 0x000000000270d999 (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x270d999)
#27 0x0000000001e53c83 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x1e53c83)
#28 0x000000000270dcf4 (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x270dcf4)
#29 0x00000000026d99dd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x26d99dd)
#30 0x00000000026da2ad clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x26da2ad)
#31 0x00000000026e93ec clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0x26e93ec)
#32 0x0000000000ac4d48 clang_main(int, char**, llvm::ToolContext const&) (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0xac4d48)
#33 0x0000000000a06d34 main (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0xa06d34)
#34 0x00007f36b0e7c083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#35 0x0000000000abf347 _start (~/clang_test/open-source/clang_for_arm/clang18/bin/clang-18+0xabf347)
clang-18: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 18.1.3
Target: arm-none-unknown-eabi
Thread model: posix
InstalledDir: ~/clang_test/open-source/clang_for_arm/clang18/bin
clang-18: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-18: note: diagnostic msg: /tmp/arm_float_to_f16-5fc438.c
clang-18: note: diagnostic msg: /tmp/arm_float_to_f16-5fc438.sh
clang-18: note: diagnostic msg:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions