[all-commits] [llvm/llvm-project] 4d0230: [BPF] improve error handling for unsupported sdiv, ...

Yingchi Long via All-commits all-commits at lists.llvm.org
Mon Dec 11 11:37:09 PST 2023


  Branch: refs/heads/users/inclyc/bpf-dont-crash-sdiv-srem
  Home:   https://github.com/llvm/llvm-project
  Commit: 4d0230b4f904f3615ddee2796ddef2492973b8de
      https://github.com/llvm/llvm-project/commit/4d0230b4f904f3615ddee2796ddef2492973b8de
  Author: Yingchi Long <i at lyc.dev>
  Date:   2023-12-12 (Tue, 12 Dec 2023)

  Changed paths:
    M llvm/lib/Target/BPF/BPFISelDAGToDAG.cpp
    M llvm/lib/Target/BPF/BPFISelLowering.cpp
    M llvm/lib/Target/BPF/BPFISelLowering.h
    M llvm/test/CodeGen/BPF/sdiv_error.ll

  Log Message:
  -----------
  [BPF] improve error handling for unsupported sdiv, srem

Currently on mcpu=v3 we do not support sdiv, srem instructions.
And the backend crashes with stacktrace & coredump, which is misleading
for end users, as this is not a "bug"

Add llvm bug reporting for sdiv/srem on ISel legalize-op phase.

For clang frontend we can get detailed location & bug report.

    $ build/bin/clang -g -target bpf -c local/sdiv.c
    local/sdiv.c:1:35: error: unsupported signed division, please convert to unsigned div/mod.
        1 | int sdiv(int a, int b) { return a / b; }
          |                                   ^
    1 error generated.

Fixes: #70433
Fixes: #48647




More information about the All-commits mailing list