Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Clang crashes compiling valgrind Thumb2/arm #39008

Open Quuxplusone opened 5 years ago

Quuxplusone commented 5 years ago
Bugzilla Link PR40036
Status CONFIRMED
Importance P enhancement
Reported by Khem Raj (raj.khem@gmail.com)
Reported on 2018-12-14 19:26:05 -0800
Last modified on 2018-12-17 13:35:49 -0800
Version 7.0
Hardware Other All
CC diana.picus@linaro.org, efriedma@quicinc.com, llvm-bugs@lists.llvm.org, neeilans@live.com, rengolin@gmail.com, richard-llvm@metafoo.co.uk, smithp352@googlemail.com
Fixed by commit(s)
Attachments vcvt_fixed_float_VFP-b24785.sh (7218 bytes, text/x-sh)
vcvt_fixed_float_VFP-b24785.c (91690 bytes, text/plain)
Blocks
Blocked by
See also
Created attachment 21228
shell script

Attached testcase and script to run the compiler
Quuxplusone commented 5 years ago

Attached vcvt_fixed_float_VFP-b24785.sh (7218 bytes, text/x-sh): shell script

Quuxplusone commented 5 years ago

Attached vcvt_fixed_float_VFP-b24785.c (91690 bytes, text/plain): testcase

Quuxplusone 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?

Quuxplusone 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!
Quuxplusone 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.

Quuxplusone 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.