[llvm-bugs] [Bug 42838] New: builtins for ARM M4f (armv7e-m) incorrectly use double precision floating point instructions

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 31 01:03:20 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=42838

            Bug ID: 42838
           Summary: builtins for ARM M4f (armv7e-m) incorrectly use double
                    precision floating point instructions
           Product: compiler-rt
           Version: 9.0
          Hardware: Other
                OS: other
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: builtins
          Assignee: unassignedbugs at nondot.org
          Reporter: pu.y at delley.net
                CC: llvm-bugs at lists.llvm.org

Compiling compiler-rt for ARM M4f (armv7e-m) fails with the following error in
a number of assembly files: "error: instruction requires: double precision
VFP". The source-code suggests that compiler-rt uses the builtin
implementations targeting the VFPv2 instruction set for both armv7-m and
armv7e-m. According to the ARMv7-M Architecture Reference Manual
(https://static.docs.arm.com/ddi0403/eb/DDI0403E_B_armv7m_arm.pdf, page 22),
armv7(e)-m effectively supports three different floating point extensions,
FPv4-SP, FPv5-SP and FPv5, where only the last one supports double precision
floating point. The other two are single-precision only restrictions of the
VFPv4 and VFPv5 equivalents of the ARM -A and -R profile instructions. M4f
implement FPv4-SP and M7f (typically?) implement FPv5. 

The CMake invocation that was tested (LLVM 9.0.0rc1, out-of-tree build,
LLVM/Clang previously compiled with default target triple "armv7em-none-eabi")
is as follows:

```bash

XTARGET=armv7em-none-eabi
XCPU=cortex-m4
XCPUDIR=cortex-m4f
XFPU="-mfloat-abi=hard -mfpu=fpv4-sp-d16"
XABI="-mthumb -mabi=aapcs"

XOPTFLAGS="-g -O2 -fomit-frame-pointer -fdata-sections -ffunction-sections"

CXX_FLAGS="--target=${XTARGET} -mcpu=${XCPU} ${XFPU} ${XABI} ${XOPTFLAGS}"
CXX_DEFINES=""
CXX_INCLUDE_PATH=""

COMPILER_FLAGS="${CXX_FLAGS} ${CXX_DEFINES} ${CXX_INCLUDE_PATH}"

cmake -GNinja -Wno-dev \
   -DCMAKE_TRY_COMPILE_TARGET_TYPE=STATIC_LIBRARY \
   -DCMAKE_SYSTEM_PROCESSOR=arm \
   -DCMAKE_SYSTEM_NAME=Generic \
   -DCMAKE_CROSSCOMPILING=ON \
   -DUNIX=1 \
   -DCMAKE_CXX_COMPILER_FORCED=TRUE \
   -DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX} \
   -DCMAKE_BUILD_TYPE=Release \
   -DCMAKE_C_COMPILER_TARGET=${XTARGET} \
   -DCMAKE_ASM_COMPILER_TARGET=${XTARGET} \
   -DCMAKE_C_COMPILER=${INSTALL_PREFIX}/bin/clang \
   -DCMAKE_CXX_COMPILER=${INSTALL_PREFIX}/bin/clang++ \
   -DCMAKE_LINKER=${INSTALL_PREFIX}/bin/clang \
   -DCMAKE_AR=${INSTALL_PREFIX}/bin/llvm-ar \
   -DCMAKE_RANLIB=${INSTALL_PREFIX}/bin/llvm-ranlib \
   -DLLVM_CONFIG_PATH=${BUILD_ROOT}/llvm/bin/llvm-config \
    -DLLVM_ENABLE_SPHINX=False \
    -DLLVM_INCLUDE_TESTS=False \
    -DLLVM_ABI_BREAKING_CHECKS=WITH_ASSERTS \
    -DLLVM_TARGETS_TO_BUILD="ARM" \
    -DLLVM_DEFAULT_TARGET_TRIPLE="armv7em-none-eabi" \
    -DLLVM_ENABLE_LLD=ON \
    -DLLVM_ENABLE_LIBCXX=ON \
   -DCMAKE_SYSROOT=${SYSROOT} \
   -DCMAKE_SYSROOT_LINK=${SYSROOT} \
   -DCMAKE_C_FLAGS="${COMPILER_FLAGS}" \
   -DCMAKE_ASM_FLAGS="${COMPILER_FLAGS}" \
   -DCMAKE_CXX_FLAGS="${COMPILER_FLAGS}" \
   -DCMAKE_EXE_LINKER_FLAGS=-L${SYSROOT}/lib \
   -DCOMPILER_RT_OS_DIR="baremetal" \
   -DCOMPILER_RT_BUILD_BUILTINS=ON \
   -DCOMPILER_RT_BUILD_SANITIZERS=OFF \
   -DCOMPILER_RT_BUILD_XRAY=OFF \
   -DCOMPILER_RT_BUILD_LIBFUZZER=OFF \
   -DCOMPILER_RT_BUILD_PROFILE=OFF \
   -DCOMPILER_RT_BAREMETAL_BUILD=ON \
   -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON \
   -DCOMPILER_RT_INCLUDE_TESTS=OFF \
   -DCOMPILER_RT_USE_LIBCXX=ON \
    ${LLVM_PROJECT_SRC_ROOT}/compiler-rt

```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190731/d226e126/attachment.html>


More information about the llvm-bugs mailing list