Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

arm64 global isel: LLVM ERROR: unable to legalize instruction: %2:_(s16), %3:_(s1) = G_UADDO %1:_, %4:_ (in function: slice) #42951

Closed Quuxplusone closed 4 years ago

Quuxplusone commented 4 years ago
Bugzilla Link PR43981
Status RESOLVED FIXED
Importance P enhancement
Reported by John Regehr (regehr@cs.utah.edu)
Reported on 2019-11-12 08:40:38 -0800
Last modified on 2019-12-17 16:32:14 -0800
Version trunk
Hardware PC Linux
CC aemerson@apple.com, daniel_l_sanders@apple.com, htmldeveloper@gmail.com, jpaquette@apple.com, llvm-bugs@lists.llvm.org, nunoplopes@sapo.pt, quentin.colombet@gmail.com, xiaoqing_wu@apple.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
I'm seeing some crashes when trying to compile small functions to arm64 using
global isel. This is on Ubuntu 18.04 and the LLVM is from Nov 11.

If these bugs aren't interesting please let me know.

$ cat w16r1_1376-stripped.ll
; ModuleID = '<stdin>'
source_filename = "w16r1_1376.ll"

define i64 @slice(i64) {
  %2 = trunc i64 %0 to i16
  %3 = add nsw i16 %2, 2
  %4 = icmp ult i16 %3, %2
  %5 = zext i1 %4 to i64
  ret i64 %5
}

$ llc -march=arm64 -global-isel w16r1_1376-stripped.ll
LLVM ERROR: unable to legalize instruction: %2:_(s16), %3:_(s1) = G_UADDO %1:_,
%4:_ (in function: slice)

$ llc --version
LLVM (http://llvm.org/):
  LLVM version 10.0.0git
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: broadwell

  Registered Targets:
    aarch64    - AArch64 (little endian)
    aarch64_32 - AArch64 (little endian ILP32)
    aarch64_be - AArch64 (big endian)
    amdgcn     - AMD GCN GPUs
    arm        - ARM
    arm64      - ARM64 (little endian)
    arm64_32   - ARM64 (little endian ILP32)
    armeb      - ARM (big endian)
    bpf        - BPF (host endian)
    bpfeb      - BPF (big endian)
    bpfel      - BPF (little endian)
    hexagon    - Hexagon
    lanai      - Lanai
    mips       - MIPS (32-bit big endian)
    mips64     - MIPS (64-bit big endian)
    mips64el   - MIPS (64-bit little endian)
    mipsel     - MIPS (32-bit little endian)
    msp430     - MSP430 [experimental]
    nvptx      - NVIDIA PTX 32-bit
    nvptx64    - NVIDIA PTX 64-bit
    ppc32      - PowerPC 32
    ppc64      - PowerPC 64
    ppc64le    - PowerPC 64 LE
    r600       - AMD GPUs HD2XXX-HD6XXX
    riscv32    - 32-bit RISC-V
    riscv64    - 64-bit RISC-V
    sparc      - Sparc
    sparcel    - Sparc LE
    sparcv9    - Sparc V9
    systemz    - SystemZ
    thumb      - Thumb
    thumbeb    - Thumb (big endian)
    wasm32     - WebAssembly 32-bit
    wasm64     - WebAssembly 64-bit
    x86        - 32-bit X86: Pentium-Pro and above
    x86-64     - 64-bit X86: EM64T and AMD64
    xcore      - XCore
$
Quuxplusone commented 4 years ago

+Amara and Jessica since they work on the AArch64 backend

Quuxplusone commented 4 years ago

We have known missing support for some constructs in GlobalISel, so these cases in normal compilation should be falling back to SDAG. For most bugs like these I don't think it's worth reporting unless there's a crash even with fallbacks enabled, or there's some miscompilation happening.

Quuxplusone commented 4 years ago

Great, thanks -- I hadn't known about the fallback.

Are we talking about -global-isel-abort? If so, what numeric value for this option would you recommend?

Quuxplusone commented 4 years ago
It depends on if you want diagnostics when you fall back or not.

-global-isel-abort=0 => Fall back to SelectionDAG when you can't select
something
-global-isel-abort=2 => Same thing, but also emit a diagnostic when you fall
back

I usually use -global-isel-abort=2 during development.
Quuxplusone commented 4 years ago

Awesome, I'll only report bugs which make it through this.

Quuxplusone commented 4 years ago

(I'll let one of y'all close this but I have no reason for it to be open if it's not helpful.)

Quuxplusone commented 4 years ago
(In reply to John Regehr from comment #6)
> (I'll let one of y'all close this but I have no reason for it to be open if
> it's not helpful.)

Thanks John for filing this!

In general, I would rather that we keep them open until we fix the fallback.
Knowing that we still fall back in some places is a valuable source of
information IMHO.

Bottom line, please keep filing PRs for the cases where you see GISel falls
back (i.e., using the -global-isel-abort=2 that Jessica mentioned.)
Quuxplusone commented 4 years ago

Posted a fix for review: https://reviews.llvm.org/D71587

Quuxplusone commented 4 years ago

Fixed in a17619e0b097 (https://reviews.llvm.org/rGa17619e0b097)