llvm / llvm-project

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

LLVM asserts in ARM ISel with "This value type is not natively supported!" while compiling Gecko #39804

Open llvmbot opened 5 years ago

llvmbot commented 5 years ago
Bugzilla Link 40458
Version 6.0
OS Linux
Attachments clang crash log
Reporter LLVM Bugzilla Contributor
CC @fhahn,@zygoloid,@rnk,@smithp35

Extended Description

When I compiler firefox gecko48 with clang, I encounter the clang crash when compiling gecko/js/src/ctypes/CTypes.cpp.

Looks like clang is crashed while compiling this function.

js::ctypes::GetDeflatedUTF8StringLength()

Not quite sure how to debug further or how to find exactly line of code leads to clang crash.

smithp35 commented 5 years ago

I haven't looked into the crash in any great detail, just picking on the target feature string.

There is a combination of armv4-t with a -target-feature +vfp3 and -target-feature +neon. This is not a legal ARM Architecture. The target-feature +neon requires armv7-a or armv7-r. I don't believe vfp3 is not supported on armv4-t either but I don't think that is the problem as we have -mfloat-abi=soft.

If I remove the +neon this will compile correctly, as is also the case if we raise the target architecture to armv7a v9a --triple thumbv7a-linux-android (remember to remove or alter --target-cpu to a v7a cpu like cortex-a9. There is still a problem here as we shouldn't get as far as an assertion, but I'd be willing to bet that this something to do with something not supported on v4t being introduced by neon.

As far as I know the earliest Android supported architecture is armv6 for the arm1176. This does not support neon either. I think the latest versions of Android require armv7-a and neon.

rnk commented 5 years ago

A reduction:

$ cat ctypes.cpp char a, c; int b; unsigned int d; int e() { int f; c = a + b; for (; a != c; a++) { d = *a; f++; } return f; }

$ clang -cc1 -triple thumbv4t--linux-android -emit-obj -target-cpu arm7tdmi -target-feature +soft-float-abi -target-feature -fp-only-sp -target-feature -d16 -target-feature +vfp3 -target-feature -fp16 -target-feature -vfp4 -target-feature -fp-armv8 -target-feature +neon -target-feature -crypto -target-feature +strict-align -target-abi aapcs-linux -mfloat-abi soft -O3 -std=gnu++14 -vectorize-loops -vectorize-slp -x c++ -w ctypes.cpp ... clang: /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/CodeGen/TargetLowering.h:627: virtual const llvm::TargetRegisterClass *llvm::TargetLoweringBase::getRegClassFor(llvm::MVT) const: Assertion `RC && "This value type is not natively supported!"' failed. ...

rnk commented 5 years ago

Stack says it's crashing in ARM ISel:

  1. parser at end of file
  2. Code generation
  3. Running pass 'Function Pass Manager' on module 'ctypes.cpp'.
  4. Running pass 'ARM Instruction Selection' on function '@_ZN2js6ctypes27GetDeflatedUTF8StringLengthIhEEjP9JSContextPKT_j'

    ​0 0x0000000004099179 PrintStackTrace /usr/local/google/home/rnk/llvm-project/llvm/lib/Support/Unix/Signals.inc:494:13

    ​1 0x0000000004099179 PrintStackTraceSignalHandler(void*) /usr/local/google/home/rnk/llvm-project/llvm/lib/Support/Unix/Signals.inc:557:0

    ​2 0x0000000004096f38 llvm::sys::RunSignalHandlers() /usr/local/google/home/rnk/llvm-project/llvm/lib/Support/Signals.cpp:69:18

    ​3 0x0000000004099596 SignalHandler(int) /usr/local/google/home/rnk/llvm-project/llvm/lib/Support/Unix/Signals.inc:357:1

    ​4 0x00007fb3764340c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)

    ​5 0x00007fb374fc5fcf gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x32fcf)

    ​6 0x00007fb374fc73fa abort (/lib/x86_64-linux-gnu/libc.so.6+0x343fa)

    ​7 0x00007fb374fbee37 (/lib/x86_64-linux-gnu/libc.so.6+0x2be37)

    ​8 0x00007fb374fbeee2 (/lib/x86_64-linux-gnu/libc.so.6+0x2bee2)

    ​9 0x0000000002aa8dce (/usr/local/google/home/rnk/llvm-project/build/bin/clang+0x2aa8dce)

    ​10 0x0000000004de633c llvm::InstrEmitter::getVR(llvm::SDValue, llvm::DenseMap<llvm::SDValue, unsigned int, llvm::DenseMapInfo, llvm::detail::DenseMapPair<llvm::SDValue, unsigned int> >&) /usr/local/google/home/rnk/llvm-project/llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp:294:14

    ​11 0x0000000004de651d llvm::InstrEmitter::AddRegisterOperand(llvm::MachineInstrBuilder&, llvm::SDValue, unsigned int, llvm::MCInstrDesc const*, llvm::DenseMap<llvm::SDValue, unsigned int, llvm::DenseMapInfo, llvm::detail::DenseMapPair<llvm::SDValue, unsigned int> >&, bool, bool, bool) /usr/local/google/home/rnk/llvm-project/llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp:321:19

    ​12 0x0000000004de68c7 llvm::InstrEmitter::AddOperand(llvm::MachineInstrBuilder&, llvm::SDValue, unsigned int, llvm::MCInstrDesc const*, llvm::DenseMap<llvm::SDValue, unsigned int, llvm::DenseMapInfo, llvm::detail::DenseMapPair<llvm::SDValue, unsigned int> >&, bool, bool, bool) /usr/local/google/home/rnk/llvm-project/llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp:464:1

    ​13 0x0000000004de9111 llvm::InstrEmitter::EmitMachineNode(llvm::SDNode*, bool, bool, llvm::DenseMap<llvm::SDValue, unsigned int, llvm::DenseMapInfo, llvm::detail::DenseMapPair<llvm::SDValue, unsigned int> >&) /usr/local/google/home/rnk/llvm-project/llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp:911:5

    ​14 0x0000000004de0bfe llvm::ScheduleDAGSDNodes::EmitSchedule(llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>&)::$_0::operator()(llvm::SDNode*, bool, bool, llvm::DenseMap<llvm::SDValue, unsigned int, llvm::DenseMapInfo, llvm::detail::DenseMapPair<llvm::SDValue, unsigned int> >&) const /usr/local/google/home/rnk/llvm-project/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp:831:53

    ​15 0x0000000004de0404 llvm::ScheduleDAGSDNodes::EmitSchedule(llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>&) /usr/local/google/home/rnk/llvm-project/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp:892:9

    ​16 0x0000000004d6029f llvm::SelectionDAGISel::CodeGenAndEmitDAG() /usr/local/google/home/rnk/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:968:42

    ​17 0x0000000004d5caea llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) /usr/local/google/home/rnk/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1813:7

    ​18 0x0000000004d59003 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) /usr/local/google/home/rnk/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:497:7

rnk commented 5 years ago

I repro'd and started a reduction.

llvmbot commented 5 years ago

It would be helpful if you could attach the bitcode file generated by passing '-emit-llvm' to Clang.

I use the command in below URL to generate bitcode.
https://pastebin.com/Qbj93zkS

The bitcode is located in https://drive.google.com/file/d/1OOCxpTcmY_AVIhp8uvkxzaG8iUbMIxJP/view?usp=sharing

llvmbot commented 5 years ago

Preprocessed source(s) and associated run script(s) are located at: https://drive.google.com/file/d/195yKyGQ6jxJpid2H9Uknd2vwizDWDe71/view?usp=sharing

fhahn commented 5 years ago

Looks like the segfault is in the backend (Machine Loop Invariant Code Motion) building for thumbv4t--linux-android. It would be helpful if you could attach the bitcode file generated by passing '-emit-llvm' to Clang.

Also, it looks like you are using clang 6, which is about a year old. Any chance you could try with a more recent build/release? If you could use a build with assertions enabled, that would be helpful too, as the issue might appear earlier.