llvm / llvm-project

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

Clang crashes compiling valgrind Thumb2/arm #39383

Open kraj opened 5 years ago

kraj commented 5 years ago
Bugzilla Link 40036
Version 7.0
OS All
Attachments shell script, testcase
CC @rovka,@efriedma-quic,@rengolin,@zygoloid,@smithp35

Extended Description

Attached testcase and script to run the compiler

efriedma-quic commented 5 years ago

I see a three issues here:

  1. ARMTargetLowering::getRegForInlineAsmConstraint should handle "w" with an integer input (by returning &ARM::SPRRegClass and letting SelectionDAGBuilder insert the appropriate cast).
  2. patchMatchingInput in SelectionDAGBuilder.cpp emits a spurious error message if you try to match an i32 with a f32, even if they would otherwise be compatible.
  3. patchMatchingInput should use emitInlineAsmError to emit error messages on invalid inline asm, not report_fatal_error.
rengolin commented 5 years ago

I think the error is about int input with float output.

My inline-asm-fu is very rusty, but that sounds to me like a valid use of vcvt.

rengolin commented 5 years ago

This is the reduced case: a() { int b; float c; asm("" : "=w"(c) : "0"(b)); }

$ clang -target thumbv7ve-yoe-linux-musleabi -c vcvt_fixed_float_VFP-b24785.c vcvt_fixed_float_VFP-b24785.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int] a() { ^ vcvt_fixed_float_VFP-b24785.c:5:1: warning: control reaches end of non-void function [-Wreturn-type] } ^ fatal error: error in backend: Unsupported asm: input constraint with a matching output constraint of incompatible type!

rengolin commented 5 years ago

I'm getting:

fatal error: error in backend: Unsupported asm: input constraint with a matching output constraint of incompatible type!

Is that what you see, too?