Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Crash in ARM backend for fmaxnum/fminnum #34345

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR35372
Status NEW
Importance P enhancement
Reported by Stephen Hines (srhines@google.com)
Reported on 2017-11-20 17:27:53 -0800
Last modified on 2017-11-21 12:18:21 -0800
Version trunk
Hardware PC Linux
CC diana.picus@linaro.org, kristof.beyls@arm.com, llvm-bugs@lists.llvm.org, pirama@google.com, srhines@google.com, yvan.roux@linaro.org
Fixed by commit(s)
Attachments bugpoint-reduced-simplified.ll (2123 bytes, text/plain)
Blocks
Blocked by
See also
Created attachment 19451
reduced ll file

The attached test case breaks for fmaxnum. We also tested a few variations in
this source file. Changing the call to fminnum also will crash similarly. If we
remove the fp-armv8 flag, then the bug goes away (but the new instructions
aren't used either). There are also slightly different crashes if you change a
constant value from -3.276800e+04 to -3.376800e+04, but it isn't obvious if
this is just a different manifestation of the same bug.

$ llc bugpoint-reduced-simplified.ll
LLVM ERROR: Cannot select: t12: v4f32 = fmaxnum t22, undef:v4f32
  t22: v4f32 = bitcast t21
    t21: v4i32 = ARMISD::VMOVIMM TargetConstant:i32<1735>
      t20: i32 = TargetConstant<1735>
  t11: v4f32 = undef
In function: _ZN7android11volumeMultiILi4ELi8EsffisEEvPT1_jPKT2_PT4_PKT3_T5_
Quuxplusone commented 6 years ago

Attached bugpoint-reduced-simplified.ll (2123 bytes, text/plain): reduced ll file

Quuxplusone commented 6 years ago

I should note that part of the problem might be related to armv8 + "krait" (as opposed to "kryo"). Pirama noticed this particular aspect of the issue, so it is possible that the build misconfiguration is causing the problem. Still, I would expect that we get a proper error message for that misconfiguration, and not a crash.

Quuxplusone commented 6 years ago

Right, after changing "target-cpu"="krait" to "target-cpu"="kryo" in the function attributes, this no longer crashes.

krait seems to be a v7a core, kryo a v8a core.

I'm not sure what the root issue is here. Maybe it's the front-end generating a call to the llvm.maxnum intrinsic (see https://llvm.org/docs/LangRef.html#llvm-maxnum-intrinsic ) which may not be supported when targeting pre-v8a?

Quuxplusone commented 6 years ago

My guess is that clang was called with something like:

clang -target armv7--linux-android -mcpu=krait -mfpu=neon-fp-armv8 ...

Otherwise I don't see how target-features can contain "...,+fp-armv8,...+neon,+vfp4,..." in section attributes #0, given that krait cpu is indeed defined as an ARMv7a core with VPFv4 features.

I'm still too new in llvm to say where and how incoherent options has to be handled, but it seems to be the issue for me here (fmaxnum/fminnum are used to generate vmaxnm/vminnm instructions which are only available on ARMv8 cores, see http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0802b/CIHFCJCF.html).