llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.76k stars 11.89k forks source link

asm volatile causes "Assertion `ConstraintID != InlineAsm::Constraint_Unknown" #43926

Open 1b2719f9-fd5c-4fac-b091-4efad0235ed7 opened 4 years ago

1b2719f9-fd5c-4fac-b091-4efad0235ed7 commented 4 years ago
Bugzilla Link 44581
Version trunk
OS All
Attachments cflag changes for openJDK, sh file created by llvm, file created by llvm
CC @Arnaud-de-Grandmaison-ARM,@smithp35

Extended Description

Using this build: http://lab.llvm.org:8011/builders/clang-aarch64-linux-build-cache/builds/21031 On Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-45-generic aarch64)

Building OpenJDK recent HEAD (Fri Jan 17 16:17:22 2020 +0100) from http://hg.openjdk.java.net/jdk/jdk

Firstly, I needed to add extra Cflags to prevent new warnings. See the attached flag.diff

I then configure and built with: JAVA_HOME=/usr/java/jdk-12.0.1+12/ CC=clang CXX=clang++ bash ../../configure --with-toolchain-type=clang --with-debug-level=release; make images JOBS=55

The following error occurs part way through the build.

clang++: /home/buildslave/buildslave/clang-aarch64-linux-build-cache/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:8383: void llvm::SelectionDAGBuilder::visitInlineAsm(llvm::ImmutableCallSite): Assertion `ConstraintID != InlineAsm::Constraint_Unknown && "Failed to convert memory constraint code to constraint id."' failed. Stack dump:

  1. Program arguments: /home/alahay01/llvm/clang-2020-01-17_14-50-39-b21031/bin//clang++ -MMD -MF /home/alahay01/work/jdkHEAD/build/clang10-release/hotspot/variant-server/libjvm/objs/compileBroker.d -include-pch /home/alahay01/work/jdkHEAD/build/clang10-release/hotspot/variant-server/libjvm/objs/precompiled/precompiled.hpp.pch -DSTDC_FORMAT_MACROS -DSTDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D_GNU_SOURCE -pipe -fno-rtti -fno-exceptions -fvisibility=hidden -fno-strict-aliasing -fno-omit-frame-pointer -flimit-debug-info -mno-omit-leaf-frame-pointer -mstack-alignment=16 -mllvm -inlinehint-threshold=100000 -DSUPPORTS_CLOCK_MONOTONIC -DLINUX -Wall -Wextra -Wformat=2 -Wpointer-arith -Wsign-compare -Wreorder -Wunused-function -Wundef -Wunused-value -Woverloaded-virtual -fPIC -fmacro-prefix-map=/= -DVM_LITTLE_ENDIAN -D_LP64=1 -DPRODUCT -DTARGET_ARCH_aarch64 -DINCLUDE_SUFFIX_OS=_linux -DINCLUDE_SUFFIX_CPU=_aarch64 -DINCLUDE_SUFFIX_COMPILER=_gcc -DTARGET_COMPILER_gcc -DAARCH64 -DHOTSPOT_LIB_ARCH="aarch64" -DCOMPILER1 -DCOMPILER2 -DDTRACE_ENABLED -I/home/alahay01/work/jdkHEAD/build/clang10-release/hotspot/variant-server/gensrc/adfiles -I/home/alahay01/work/jdkHEAD/src/hotspot/share -I/home/alahay01/work/jdkHEAD/src/hotspot/os/linux -I/home/alahay01/work/jdkHEAD/src/hotspot/os/posix -I/home/alahay01/work/jdkHEAD/src/hotspot/cpu/aarch64 -I/home/alahay01/work/jdkHEAD/src/hotspot/os_cpu/linux_aarch64 -I/home/alahay01/work/jdkHEAD/build/clang10-release/hotspot/variant-server/gensrc -I/home/alahay01/work/jdkHEAD/src/hotspot/share/precompiled -I/home/alahay01/work/jdkHEAD/src/hotspot/share/include -I/home/alahay01/work/jdkHEAD/src/hotspot/os/posix/include -I/home/alahay01/work/jdkHEAD/build/clang10-release/support/modules_include/java.base -I/home/alahay01/work/jdkHEAD/build/clang10-release/support/modules_include/java.base/linux -I/home/alahay01/work/jdkHEAD/src/java.base/share/native/libjimage -g -Wno-unknown-warning-option -Wno-unused-parameter -Wno-unused -Wno-tautological-compare -Wno-undefined-var-template -Wno-sometimes-uninitialized -Wno-unknown-pragmas -Wno-delete-non-virtual-dtor -Wno-missing-braces -Wno-char-subscripts -Wno-ignored-qualifiers -Wno-missing-field-initializers -Wno-mismatched-tags -Werror -O3 -Wno-deprecated-copy -Wno-misleading-indentation -Wno-string-compare -Wno-sizeof-array-div -c -o /home/alahay01/work/jdkHEAD/build/clang10-release/hotspot/variant-server/libjvm/objs/compileBroker.o /home/alahay01/work/jdkHEAD/src/hotspot/share/compiler/compileBroker.cpp
  2. parser at end of file
  3. Code generation
  4. Running pass 'Function Pass Manager' on module '/home/alahay01/work/jdkHEAD/src/hotspot/share/compiler/compileBroker.cpp'.
  5. Running pass 'AArch64 Instruction Selection' on function '@_ZN13CompileBroker25invoke_compiler_on_methodEP11CompileTask' Compiling 3 files for BUILD_VM_COMPILER_SERVICEPROVIDER_PROCESSOR

    ​0 0x00000000019e9cec PrintStackTraceSignalHandler(void*) (/home/alahay01/llvm/clang-2020-01-17_14-50-39-b21031/bin//clang+++0x19e9cec)

    clang-11: error: clang frontend command failed due to signal (use -v to see invocation) clang version 11.0.0 (/home/buildslave/buildslave/clang-aarch64-linux-build-cache/llvm/clang 8eb4d25a0943bce6e8a4859825dce4f67a4f6384) Target: aarch64-unknown-linux-gnu Thread model: posix InstalledDir: /home/alahay01/llvm/clang-2020-01-17_14-50-39-b21031/bin clang-11: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. clang-11: note: diagnostic msg:


PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-11: note: diagnostic msg: /tmp/compileBroker-123210.cpp clang-11: note: diagnostic msg: /tmp/compileBroker-123210.sh clang-11: note: diagnostic msg:


Running the newly created script reproduced the error.

1b2719f9-fd5c-4fac-b091-4efad0235ed7 commented 4 years ago

Note that the attached failure isn't useful (or possibly correct) C code.

The code is a heavy reduction of the code created when using the STAP_PROBE macros found in /usr/include/aarch64-linux-gnu/sys/sdt.h. These macros create a large block of asm volatile code. When used they create exactly the same error as my 1 line attached file.

An alternative, more real-world way of producing the same error is by simply using:

include <sys/sdt.h>

void func() { STAP_PROBE1("a","b","c"); };

1b2719f9-fd5c-4fac-b091-4efad0235ed7 commented 4 years ago

sh file created by crash report

1b2719f9-fd5c-4fac-b091-4efad0235ed7 commented 4 years ago

C file created by crash report

1b2719f9-fd5c-4fac-b091-4efad0235ed7 commented 4 years ago

Ok, I've reduced this down to a single line!

$ cat volatile.cpp void func() { asm volatile ("\n" :: "nop" ("")); }

$ /home/alahay01/llvm/clang-2020-01-17_14-50-39-b21031/bin/clang-11 -c volatile.cpp clang-11: /home/buildslave/buildslave/clang-aarch64-linux-build-cache/llvm/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:8383: void llvm::SelectionDAGBuilder::visitInlineAsm(llvm::ImmutableCallSite): Assertion `ConstraintID != InlineAsm::Constraint_Unknown && "Failed to convert memory constraint code to constraint id."' failed. Stack dump:

  1. Program arguments: /home/alahay01/llvm/clang-2020-01-17_14-50-39-b21031/bin/clang-11 -c volatile.cpp
  2. parser at end of file
  3. Code generation
  4. Running pass 'Function Pass Manager' on module 'volatile.cpp'.
  5. Running pass 'AArch64 Instruction Selection' on function '@_Z4funcv'

    ​0 0x00000000019e9cec PrintStackTraceSignalHandler(void*) (/home/alahay01/llvm/clang-2020-01-17_14-50-39-b21031/bin/clang-11+0x19e9cec)

    clang-11: error: clang frontend command failed due to signal (use -v to see invocation) clang version 11.0.0 (/home/buildslave/buildslave/clang-aarch64-linux-build-cache/llvm/clang 8eb4d25a0943bce6e8a4859825dce4f67a4f6384) Target: aarch64-unknown-linux-gnu Thread model: posix InstalledDir: /home/alahay01/llvm/clang-2020-01-17_14-50-39-b21031/bin clang-11: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script. clang-11: note: diagnostic msg:


PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: Preprocessed source(s) and associated run script(s) are located at: clang-11: note: diagnostic msg: /tmp/volatile-f5dca4.cpp clang-11: note: diagnostic msg: /tmp/volatile-f5dca4.sh clang-11: note: diagnostic msg:


LLVM ERROR: out of memory Aborted

1b2719f9-fd5c-4fac-b091-4efad0235ed7 commented 4 years ago

the produced cpp file is 274001 lines / 11M. I'll try and reduce this down a little and update next week.

1b2719f9-fd5c-4fac-b091-4efad0235ed7 commented 4 years ago

CPP file is too big to attach. Finding a way to work around.