Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Inline assembly constraint "X" triggers assert #26492

Closed Quuxplusone closed 8 years ago

Quuxplusone commented 8 years ago
Bugzilla Link PR26493
Status RESOLVED FIXED
Importance P normal
Reported by Kristof Beyls (kristof.beyls@gmail.com)
Reported on 2016-02-05 09:31:22 -0800
Last modified on 2016-05-10 04:49:03 -0700
Version trunk
Hardware PC All
CC jsweval@arxan.com, llvm-bugs@lists.llvm.org, rengolin@gmail.com, silviu.baranga@arm.com, srhines@google.com
Fixed by commit(s)
Attachments
Blocks PR21420, PR27197
Blocked by
See also
When trying to build https://gitorious.org/arm-neon-tests/arm-neon-tests with
clang, clang crashes with assertion failures.

Below are 2 small reproducers, which each trigger a different assert. These
snippets use the "X" inline assembly constraint to avoid the inline assembly
being reordered with the computations happening later. The technique is
explained in detail at http://www.ethernut.de/en/documents/arm-inline-asm.html,
under section "C code optimization".

$ cat t2.c
double f2(double f, int pscr_value) {
  asm volatile("vmsr fpscr,%1" : "=X" ((f)): "r" (pscr_value));
  return f+f;
}
$ cat t3.c
typedef signed char int8_t;
typedef __attribute__((neon_vector_type(8))) int8_t int8x8_t;
void f (void)
{
  int8x8_t vector_res_int8x8;
  unsigned int fpscr;
  asm volatile ("vmsr fpscr,%1" : "=X" ((vector_res_int8x8)) : "r" (fpscr));
}
$ ~/dev/llvm.org/build/bin/clang -target armv7a-none-eabi -c -mcpu=cortex-a9  -
mfloat-abi=hard -S -O -o- t2.c
        .text
        .syntax unified
        .eabi_attribute 67, "2.09"      @ Tag_conformance
        .cpu    cortex-a9
        .eabi_attribute 6, 10   @ Tag_CPU_arch
        .eabi_attribute 7, 65   @ Tag_CPU_arch_profile
        .eabi_attribute 8, 1    @ Tag_ARM_ISA_use
        .eabi_attribute 9, 2    @ Tag_THUMB_ISA_use
        .fpu    neon-fp16
        .eabi_attribute 17, 1   @ Tag_ABI_PCS_GOT_use
        .eabi_attribute 20, 1   @ Tag_ABI_FP_denormal
        .eabi_attribute 21, 1   @ Tag_ABI_FP_exceptions
        .eabi_attribute 23, 3   @ Tag_ABI_FP_number_model
        .eabi_attribute 34, 0   @ Tag_CPU_unaligned_access
        .eabi_attribute 24, 1   @ Tag_ABI_align_needed
        .eabi_attribute 25, 1   @ Tag_ABI_align_preserved
        .eabi_attribute 28, 1   @ Tag_ABI_VFP_args
        .eabi_attribute 36, 1   @ Tag_FP_HP_extension
        .eabi_attribute 38, 1   @ Tag_ABI_FP_16bit_format
        .eabi_attribute 42, 1   @ Tag_MPextension_use
        .eabi_attribute 18, 4   @ Tag_ABI_PCS_wchar_t
        .eabi_attribute 26, 2   @ Tag_ABI_enum_size
        .eabi_attribute 14, 0   @ Tag_ABI_PCS_R9_use
        .eabi_attribute 68, 1   @ Tag_Virtualization_use
        .file   "t2.c"
Assertion failed: (ConstraintID != InlineAsm::Constraint_Unknown && "Failed to
convert memory constraint code to constraint id."), function visitInlineAsm,
file /Users/kribey01/dev/llvm.org/llvm-clang-compiler-rt
/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp, line 6401.
0  clang-3.9                0x0000000101f6f96b
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1  clang-3.9                0x0000000101f6ebe6 llvm::sys::RunSignalHandlers() +
70
2  clang-3.9                0x0000000101f70012 SignalHandler(int) + 322
3  libsystem_platform.dylib 0x00007fff8e779f1a _sigtramp + 26
4  clang-3.9                0x0000000104041fd7 clang::Stmt::StatisticsEnabled +
92386
5  clang-3.9                0x0000000101f6fe26 abort + 22
6  clang-3.9                0x0000000101f6fe01 __assert_rtn + 81
7  clang-3.9                0x00000001025e4eff
llvm::SelectionDAGBuilder::visitInlineAsm(llvm::ImmutableCallSite) + 15695
8  clang-3.9                0x00000001025cd895
llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) + 69
9  clang-3.9                0x000000010264c2e8
llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::Instruction
const>, llvm::ilist_iterator<llvm::Instruction const>, bool&) + 40
10 clang-3.9                0x000000010264bf74
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 6612
11 clang-3.9                0x0000000102649554
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 2020
12 clang-3.9                0x000000010108f4f4 (anonymous
namespace)::ARMDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 20
13 clang-3.9                0x00000001019b94dc
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 140
14 clang-3.9                0x0000000101b9acd8
llvm::FPPassManager::runOnFunction(llvm::Function&) + 328
15 clang-3.9                0x0000000101b9af2b
llvm::FPPassManager::runOnModule(llvm::Module&) + 43
16 clang-3.9                0x0000000101b9b3b6
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 806
17 clang-3.9                0x00000001020cb6be
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions
const&, clang::TargetOptions const&, clang::LangOptions const&,
llvm::StringRef, llvm::Modu
le*, clang::BackendAction, llvm::raw_pwrite_stream*) + 8750
18 clang-3.9                0x000000010223c502
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 514
19 clang-3.9                0x000000010290cdd5 clang::ParseAST(clang::Sema&,
bool, bool) + 581
20 clang-3.9                0x000000010240c69b clang::FrontendAction::Execute()
+ 75
21 clang-3.9                0x00000001023d2e81
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1073
22 clang-3.9                0x000000010244b3bf
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 4047
23 clang-3.9                0x0000000100df7da3 cc1_main(llvm::ArrayRef<char
const*>, char const*, void*) + 1491
24 clang-3.9                0x0000000100df67d0 main + 11568
25 libdyld.dylib            0x00007fff9aabd5c9 start + 1
Stack dump:
0.      Program arguments: /Users/kribey01/dev/llvm.org/build/bin/clang-3.9 -
cc1 -triple armv7-none--eabi -S -disable-free -main-file-name t2.c -mrelocation-
model static -mthread-model posix -mdisable-fp-elim -fm
ath-errno -masm-verbose -mconstructor-aliases -target-cpu cortex-a9 -target-
feature +strict-align -target-abi aapcs -mfloat-abi hard -target-linker-version
253.6 -dwarf-column-info -debugger-tuning=gdb -coverage-
file /Users/kribey01/dev/triage/android/201602_arm_neon_tests/arm-neon-tests/- -
resource-dir /Users/kribey01/dev/llvm.org/build/bin/../lib/clang/3.9.0 -O2 -
fdebug-compilation-dir /Users/kribey01/dev/triage/androi
d/201602_arm_neon_tests/arm-neon-tests -ferror-limit 19 -fmessage-length 212 -
fallow-half-arguments-and-returns -fno-signed-char -fobjc-runtime=gcc -
fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -
vectorize-slp -o - -x c t2.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 't2.c'.
4.      Running pass 'ARM Instruction Selection' on function '@f2'
clang-3.9: error: unable to execute command: Illegal instruction: 4
clang-3.9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.9.0 (ssh://kribey01@e103606-
lin.cambridge.arm.com/work/llvm.org/llvm-clang-compiler-rt/tools/clang
da6e53c2620d92ec6ff16c23af69c4e531d23417) (ssh://kribey01@e103606-
lin.cambridge.arm.com/work/llvm
.org/llvm-clang-compiler-rt bb152043ce23844ccd348b0cde05f301b1319b70)
Target: armv7a-none--eabi
Thread model: posix
InstalledDir: /Users/kribey01/dev/llvm.org/build/bin
clang-3.9: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang-3.9: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.9: note: diagnostic msg:
/var/folders/th/cnt0054d153g3xf5rt87856x_1kq80/T/t2-07d0cb.c
clang-3.9: note: diagnostic msg:
/var/folders/th/cnt0054d153g3xf5rt87856x_1kq80/T/t2-07d0cb.sh
clang-3.9: note: diagnostic msg:

********************
$ ~/dev/llvm.org/build/bin/clang -target armv7a-none-eabi -c -mcpu=cortex-a9  -
mfloat-abi=hard -S -O -o- t3.c
        .text
        .syntax unified
        .eabi_attribute 67, "2.09"      @ Tag_conformance
        .cpu    cortex-a9
        .eabi_attribute 6, 10   @ Tag_CPU_arch
        .eabi_attribute 7, 65   @ Tag_CPU_arch_profile
        .eabi_attribute 8, 1    @ Tag_ARM_ISA_use
        .eabi_attribute 9, 2    @ Tag_THUMB_ISA_use
        .fpu    neon-fp16
        .eabi_attribute 17, 1   @ Tag_ABI_PCS_GOT_use
        .eabi_attribute 20, 1   @ Tag_ABI_FP_denormal
        .eabi_attribute 21, 1   @ Tag_ABI_FP_exceptions
        .eabi_attribute 23, 3   @ Tag_ABI_FP_number_model
        .eabi_attribute 34, 0   @ Tag_CPU_unaligned_access
        .eabi_attribute 24, 1   @ Tag_ABI_align_needed
        .eabi_attribute 25, 1   @ Tag_ABI_align_preserved
        .eabi_attribute 28, 1   @ Tag_ABI_VFP_args
        .eabi_attribute 36, 1   @ Tag_FP_HP_extension
        .eabi_attribute 38, 1   @ Tag_ABI_FP_16bit_format
        .eabi_attribute 42, 1   @ Tag_MPextension_use
        .eabi_attribute 18, 4   @ Tag_ABI_PCS_wchar_t
        .eabi_attribute 26, 2   @ Tag_ABI_enum_size
        .eabi_attribute 14, 0   @ Tag_ABI_PCS_R9_use
        .eabi_attribute 68, 1   @ Tag_Virtualization_use
        .file   "t3.c"
Assertion failed: (Val && "isa<> used on a null pointer"), function doit, file
/Users/kribey01/dev/llvm.org/llvm-clang-compiler-
rt/include/llvm/Support/Casting.h, line 95.
0  clang-3.9                0x000000010721196b
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1  clang-3.9                0x0000000107210be6 llvm::sys::RunSignalHandlers() +
70
2  clang-3.9                0x0000000107212012 SignalHandler(int) + 322
3  libsystem_platform.dylib 0x00007fff8e779f1a _sigtramp + 26
4  clang-3.9                0x00000001092e3fe6 clang::Stmt::StatisticsEnabled +
92401
5  clang-3.9                0x0000000107211e26 abort + 22
6  clang-3.9                0x0000000107211e01 __assert_rtn + 81
7  clang-3.9                0x00000001078a50b7
diagnosePossiblyInvalidConstraint(llvm::LLVMContext&, llvm::Value const*,
llvm::Twine const&) + 247
8  clang-3.9                0x000000010786b062
getCopyFromParts(llvm::SelectionDAG&, llvm::SDLoc, llvm::SDValue const*,
unsigned int, llvm::MVT, llvm::EVT, llvm::Value const*, llvm::ISD::NodeType) +
2114
9  clang-3.9                0x000000010786a662
llvm::RegsForValue::getCopyFromRegs(llvm::SelectionDAG&,
llvm::FunctionLoweringInfo&, llvm::SDLoc, llvm::SDValue&, llvm::SDValue*,
llvm::Value const*) const + 2498
10 clang-3.9                0x000000010788605b
llvm::SelectionDAGBuilder::visitInlineAsm(llvm::ImmutableCallSite) + 11947
11 clang-3.9                0x000000010786f895
llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) + 69
12 clang-3.9                0x00000001078ee2e8
llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::Instruction
const>, llvm::ilist_iterator<llvm::Instruction const>, bool&) + 40
13 clang-3.9                0x00000001078edf74
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 6612
14 clang-3.9                0x00000001078eb554
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 2020
15 clang-3.9                0x00000001063314f4 (anonymous
namespace)::ARMDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 20
16 clang-3.9                0x0000000106c5b4dc
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 140
17 clang-3.9                0x0000000106e3ccd8
llvm::FPPassManager::runOnFunction(llvm::Function&) + 328
18 clang-3.9                0x0000000106e3cf2b
llvm::FPPassManager::runOnModule(llvm::Module&) + 43
19 clang-3.9                0x0000000106e3d3b6
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 806
20 clang-3.9                0x000000010736d6be
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions
const&, clang::TargetOptions const&, clang::LangOptions const&,
llvm::StringRef, llvm::Mod
le*, clang::BackendAction, llvm::raw_pwrite_stream*) + 8750
21 clang-3.9                0x00000001074de502
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 514
22 clang-3.9                0x0000000107baedd5 clang::ParseAST(clang::Sema&,
bool, bool) + 581
23 clang-3.9                0x00000001076ae69b clang::FrontendAction::Execute()
+ 75
24 clang-3.9                0x0000000107674e81
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1073
25 clang-3.9                0x00000001076ed3bf
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 4047
26 clang-3.9                0x0000000106099da3 cc1_main(llvm::ArrayRef<char
const*>, char const*, void*) + 1491
27 clang-3.9                0x00000001060987d0 main + 11568
28 libdyld.dylib            0x00007fff9aabd5c9 start + 1
Stack dump:
0.      Program arguments: /Users/kribey01/dev/llvm.org/build/bin/clang-3.9 -
cc1 -triple armv7-none--eabi -S -disable-free -main-file-name t3.c -mrelocation-
model static -mthread-model posix -mdisable-fp-elim -f
ath-errno -masm-verbose -mconstructor-aliases -target-cpu cortex-a9 -target-
feature +strict-align -target-abi aapcs -mfloat-abi hard -target-linker-version
253.6 -dwarf-column-info -debugger-tuning=gdb -coverage
file /Users/kribey01/dev/triage/android/201602_arm_neon_tests/arm-neon-tests/- -
resource-dir /Users/kribey01/dev/llvm.org/build/bin/../lib/clang/3.9.0 -O2 -
fdebug-compilation-dir /Users/kribey01/dev/triage/andro
d/201602_arm_neon_tests/arm-neon-tests -ferror-limit 19 -fmessage-length 212 -
fallow-half-arguments-and-returns -fno-signed-char -fobjc-runtime=gcc -
fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops
vectorize-slp -o - -x c t3.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 't3.c'.
4.      Running pass 'ARM Instruction Selection' on function '@f'
clang-3.9: error: unable to execute command: Illegal instruction: 4
clang-3.9: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.9.0 (ssh://kribey01@e103606-
lin.cambridge.arm.com/work/llvm.org/llvm-clang-compiler-rt/tools/clang
da6e53c2620d92ec6ff16c23af69c4e531d23417) (ssh://kribey01@e103606-
lin.cambridge.arm.com/work/llv
.org/llvm-clang-compiler-rt bb152043ce23844ccd348b0cde05f301b1319b70)
Target: armv7a-none--eabi
Thread model: posix
InstalledDir: /Users/kribey01/dev/llvm.org/build/bin
clang-3.9: note: diagnostic msg: PLEASE submit a bug report to
http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and
associated run script.
clang-3.9: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-3.9: note: diagnostic msg:
/var/folders/th/cnt0054d153g3xf5rt87856x_1kq80/T/t3-c62f0b.c
clang-3.9: note: diagnostic msg:
/var/folders/th/cnt0054d153g3xf5rt87856x_1kq80/T/t3-c62f0b.sh
clang-3.9: note: diagnostic msg:

********************
Quuxplusone commented 8 years ago

I'm assuming that similar asserts can be triggered for at least the AArch64 backend, but I haven't tested that yet.

Quuxplusone commented 8 years ago

This should now work on ARM.

Quuxplusone commented 8 years ago

Silviu, do you know of a specific CL that fixes this, or were there multiple CLs?

Quuxplusone commented 8 years ago

Sorry, should be just r267411.

Quuxplusone commented 8 years ago

Also fixed the AArch64 side in r268907.