llvm-project/llvm/test/CodeGen/BPF/dynamic-stack.ll
Yingchi Long ddf85b92aa
[BPF] improve error handling by custom lowering & fail() (#75088)
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

This also improves error handling for dynamic stack allocation:

    local/vla.c:2:3: error: unsupported dynamic stack allocation
        2 |   int b[n];
          |   ^
    1 error generated.

Fixes: https://github.com/llvm/llvm-project/issues/57171
2023-12-13 13:41:52 +08:00

9 lines
217 B
LLVM

; RUN: not llc < %s -mtriple=bpfel 2>&1 | FileCheck %s
define i64 @vla(i64 %num) {
; CHECK: unsupported dynamic stack allocation
%vla = alloca i32, i64 %num
%ret = ptrtoint ptr %vla to i64
ret i64 %ret
}