Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion llvm/include/llvm/IR/RuntimeLibcalls.td
Original file line number Diff line number Diff line change
Expand Up @@ -3464,13 +3464,22 @@ def WasmSystemLibrary
emscripten_return_address,
__stack_chk_fail, __stack_chk_guard)>;

//===----------------------------------------------------------------------===//
// BPF Runtime Libcalls
//===----------------------------------------------------------------------===//

def isBPF : RuntimeLibcallPredicate<"TT.isBPF()">;

// No calls.
def BPFSystemLibrary : SystemRuntimeLibrary<isBPF, (add)>;

//===----------------------------------------------------------------------===//
// Legacy Default Runtime Libcalls
//===----------------------------------------------------------------------===//

// TODO: Should make every target explicit.
def isDefaultLibcallArch : RuntimeLibcallPredicate<[{
TT.isMIPS() || TT.isLoongArch() || TT.isVE() || TT.isBPF() ||
TT.isMIPS() || TT.isLoongArch() || TT.isVE() ||
TT.getArch() == Triple::csky || TT.getArch() == Triple::arc ||
TT.getArch() == Triple::m68k || TT.getArch() == Triple::xtensa ||
(TT.isSystemZ() && !TT.isOSzOS())
Expand Down
4 changes: 4 additions & 0 deletions llvm/test/CodeGen/BPF/atomic-oversize.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
; RUN: llc -mtriple=bpf < %s | FileCheck %s
; XFAIL: *
; Doesn't currently build with errors
; error: unsupported atomic store
; error: unsupported atomic load

define void @test(ptr %a) nounwind {
; CHECK-LABEL: test:
Expand Down
39 changes: 0 additions & 39 deletions llvm/test/CodeGen/BPF/builtin_calls.ll

This file was deleted.

23 changes: 23 additions & 0 deletions llvm/test/CodeGen/BPF/i128_math.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
; RUN: llc -march=bpfel < %s | FileCheck %s
;
; C code for this test case:
;
; long func(long a, long b) {
; long x;
; return __builtin_mul_overflow(a, b, &x);
; }


declare { i64, i1 } @llvm.smul.with.overflow.i64(i64, i64)

define noundef range(i64 0, 2) i64 @func(i64 noundef %a, i64 noundef %b) local_unnamed_addr {
entry:
%0 = tail call { i64, i1 } @llvm.smul.with.overflow.i64(i64 %a, i64 %b)
%1 = extractvalue { i64, i1 } %0, 1
%conv = zext i1 %1 to i64
ret i64 %conv
}

; CHECK-LABEL: func
; CHECK-NOT: call __multi3
; CHECK: exit
182 changes: 14 additions & 168 deletions llvm/test/CodeGen/BPF/pr57872.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,175 +6,21 @@
define void @foo(ptr %g) {
; CHECK-LABEL: foo:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: r2 = 0
; CHECK-NEXT: r1 = *(u64 *)(r1 + 0)
; CHECK-NEXT: r2 = *(u8 *)(r1 + 83)
; CHECK-NEXT: *(u8 *)(r10 - 4) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 82)
; CHECK-NEXT: *(u8 *)(r10 - 5) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 81)
; CHECK-NEXT: *(u8 *)(r10 - 6) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 80)
; CHECK-NEXT: *(u8 *)(r10 - 7) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 79)
; CHECK-NEXT: *(u8 *)(r10 - 8) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 78)
; CHECK-NEXT: *(u8 *)(r10 - 9) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 77)
; CHECK-NEXT: *(u8 *)(r10 - 10) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 76)
; CHECK-NEXT: *(u8 *)(r10 - 11) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 75)
; CHECK-NEXT: *(u8 *)(r10 - 12) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 74)
; CHECK-NEXT: *(u8 *)(r10 - 13) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 73)
; CHECK-NEXT: *(u8 *)(r10 - 14) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 72)
; CHECK-NEXT: *(u8 *)(r10 - 15) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 71)
; CHECK-NEXT: *(u8 *)(r10 - 16) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 70)
; CHECK-NEXT: *(u8 *)(r10 - 17) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 69)
; CHECK-NEXT: *(u8 *)(r10 - 18) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 68)
; CHECK-NEXT: *(u8 *)(r10 - 19) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 67)
; CHECK-NEXT: *(u8 *)(r10 - 20) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 66)
; CHECK-NEXT: *(u8 *)(r10 - 21) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 65)
; CHECK-NEXT: *(u8 *)(r10 - 22) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 64)
; CHECK-NEXT: *(u8 *)(r10 - 23) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 63)
; CHECK-NEXT: *(u8 *)(r10 - 24) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 62)
; CHECK-NEXT: *(u8 *)(r10 - 25) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 61)
; CHECK-NEXT: *(u8 *)(r10 - 26) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 60)
; CHECK-NEXT: *(u8 *)(r10 - 27) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 59)
; CHECK-NEXT: *(u8 *)(r10 - 28) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 58)
; CHECK-NEXT: *(u8 *)(r10 - 29) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 57)
; CHECK-NEXT: *(u8 *)(r10 - 30) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 56)
; CHECK-NEXT: *(u8 *)(r10 - 31) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 55)
; CHECK-NEXT: *(u8 *)(r10 - 32) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 54)
; CHECK-NEXT: *(u8 *)(r10 - 33) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 53)
; CHECK-NEXT: *(u8 *)(r10 - 34) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 52)
; CHECK-NEXT: *(u8 *)(r10 - 35) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 51)
; CHECK-NEXT: *(u8 *)(r10 - 36) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 50)
; CHECK-NEXT: *(u8 *)(r10 - 37) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 49)
; CHECK-NEXT: *(u8 *)(r10 - 38) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 48)
; CHECK-NEXT: *(u8 *)(r10 - 39) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 47)
; CHECK-NEXT: *(u8 *)(r10 - 40) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 46)
; CHECK-NEXT: *(u8 *)(r10 - 41) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 45)
; CHECK-NEXT: *(u8 *)(r10 - 42) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 44)
; CHECK-NEXT: *(u8 *)(r10 - 43) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 43)
; CHECK-NEXT: *(u8 *)(r10 - 44) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 42)
; CHECK-NEXT: *(u8 *)(r10 - 45) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 41)
; CHECK-NEXT: *(u8 *)(r10 - 46) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 40)
; CHECK-NEXT: *(u8 *)(r10 - 47) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 39)
; CHECK-NEXT: *(u8 *)(r10 - 48) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 38)
; CHECK-NEXT: *(u8 *)(r10 - 49) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 37)
; CHECK-NEXT: *(u8 *)(r10 - 50) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 36)
; CHECK-NEXT: *(u8 *)(r10 - 51) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 35)
; CHECK-NEXT: *(u8 *)(r10 - 52) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 34)
; CHECK-NEXT: *(u8 *)(r10 - 53) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 33)
; CHECK-NEXT: *(u8 *)(r10 - 54) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 32)
; CHECK-NEXT: *(u8 *)(r10 - 55) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 31)
; CHECK-NEXT: *(u8 *)(r10 - 56) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 30)
; CHECK-NEXT: *(u8 *)(r10 - 57) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 29)
; CHECK-NEXT: *(u8 *)(r10 - 58) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 28)
; CHECK-NEXT: *(u8 *)(r10 - 59) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 27)
; CHECK-NEXT: *(u8 *)(r10 - 60) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 26)
; CHECK-NEXT: *(u8 *)(r10 - 61) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 25)
; CHECK-NEXT: *(u8 *)(r10 - 62) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 24)
; CHECK-NEXT: *(u8 *)(r10 - 63) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 23)
; CHECK-NEXT: *(u8 *)(r10 - 64) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 22)
; CHECK-NEXT: *(u8 *)(r10 - 65) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 21)
; CHECK-NEXT: *(u8 *)(r10 - 66) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 20)
; CHECK-NEXT: *(u8 *)(r10 - 67) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 19)
; CHECK-NEXT: *(u8 *)(r10 - 68) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 18)
; CHECK-NEXT: *(u8 *)(r10 - 69) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 17)
; CHECK-NEXT: *(u8 *)(r10 - 70) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 16)
; CHECK-NEXT: *(u8 *)(r10 - 71) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 15)
; CHECK-NEXT: *(u8 *)(r10 - 72) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 14)
; CHECK-NEXT: *(u8 *)(r10 - 73) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 13)
; CHECK-NEXT: *(u8 *)(r10 - 74) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 12)
; CHECK-NEXT: *(u8 *)(r10 - 75) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 11)
; CHECK-NEXT: *(u8 *)(r10 - 76) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 10)
; CHECK-NEXT: *(u8 *)(r10 - 77) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 9)
; CHECK-NEXT: *(u8 *)(r10 - 78) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 8)
; CHECK-NEXT: *(u8 *)(r10 - 79) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 7)
; CHECK-NEXT: *(u8 *)(r10 - 80) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 6)
; CHECK-NEXT: *(u8 *)(r10 - 81) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 5)
; CHECK-NEXT: *(u8 *)(r10 - 82) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 4)
; CHECK-NEXT: *(u8 *)(r10 - 83) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 3)
; CHECK-NEXT: *(u8 *)(r10 - 84) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 2)
; CHECK-NEXT: *(u8 *)(r10 - 85) = r2
; CHECK-NEXT: r2 = *(u8 *)(r1 + 1)
; CHECK-NEXT: *(u8 *)(r10 - 86) = r2
; CHECK-NEXT: r1 = *(u8 *)(r1 + 0)
; CHECK-NEXT: *(u8 *)(r10 - 87) = r1
; CHECK-NEXT: r3 = 84
; CHECK-NEXT: LBB0_1: # %load-store-loop
; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
; CHECK-NEXT: r4 = r10
; CHECK-NEXT: r4 += -88
; CHECK-NEXT: r4 += r2
; CHECK-NEXT: r5 = r1
; CHECK-NEXT: r5 += r2
; CHECK-NEXT: r5 = *(u8 *)(r5 + 0)
; CHECK-NEXT: *(u8 *)(r4 + 1) = r5
; CHECK-NEXT: r2 += 1
; CHECK-NEXT: if r3 > r2 goto LBB0_1
; CHECK-NEXT: # %bb.2: # %memcpy-split
; CHECK-NEXT: r1 = r10
; CHECK-NEXT: r1 += -88
; CHECK-NEXT: call bar
Expand Down
80 changes: 77 additions & 3 deletions llvm/test/CodeGen/BPF/warn-call.ll
Original file line number Diff line number Diff line change
@@ -1,8 +1,67 @@
; RUN: not llc -mtriple=bpfel < %s 2>&1 >/dev/null | FileCheck %s
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
; RUN: llc -mtriple=bpfel < %s | FileCheck %s

; CHECK: error: warn_call.c
; CHECK: built-in function 'memcpy'
define ptr @warn(ptr returned, ptr, i64) local_unnamed_addr #0 !dbg !6 {
; CHECK-LABEL: warn:
; CHECK: .Lfunc_begin0:
; CHECK-NEXT: .file 1 "/w/llvm/bld" "warn_call.c"
; CHECK-NEXT: .loc 1 5 0 # warn_call.c:5:0
; CHECK-NEXT: .cfi_startproc
; CHECK-NEXT: # %bb.0:
; CHECK-NEXT: #DEBUG_VALUE: warn:dst <- $r1
; CHECK-NEXT: #DEBUG_VALUE: warn:src <- $r2
; CHECK-NEXT: #DEBUG_VALUE: warn:len <- $r3
; CHECK-NEXT: r6 = r1
; CHECK-NEXT: .Ltmp0:
; CHECK-NEXT: .Ltmp1:
; CHECK-NEXT: #DEBUG_VALUE: warn:dst <- $r6
; CHECK-NEXT: .loc 1 6 2 prologue_end # warn_call.c:6:2
; CHECK-NEXT: .Ltmp2:
; CHECK-NEXT: if r3 == 0 goto LBB0_3
; CHECK-NEXT: .Ltmp3:
; CHECK-NEXT: .Ltmp4:
; CHECK-NEXT: # %bb.1: # %loop-memcpy-expansion.preheader
; CHECK-NEXT: #DEBUG_VALUE: warn:dst <- $r6
; CHECK-NEXT: #DEBUG_VALUE: warn:len <- $r3
; CHECK-NEXT: #DEBUG_VALUE: warn:src <- $r2
; CHECK-NEXT: .loc 1 0 2 is_stmt 0 # warn_call.c:0:2
; CHECK-NEXT: r4 = 0
; CHECK-NEXT: .Ltmp5:
; CHECK-NEXT: .Ltmp6:
; CHECK-NEXT: LBB0_2: # %loop-memcpy-expansion
; CHECK-NEXT: # =>This Inner Loop Header: Depth=1
; CHECK-NEXT: #DEBUG_VALUE: warn:dst <- $r6
; CHECK-NEXT: #DEBUG_VALUE: warn:len <- $r3
; CHECK-NEXT: #DEBUG_VALUE: warn:src <- $r2
; CHECK-NEXT: r5 = r6
; CHECK-NEXT: r5 += r4
; CHECK-NEXT: r0 = r2
; CHECK-NEXT: r0 += r4
; CHECK-NEXT: w0 = *(u8 *)(r0 + 0)
; CHECK-NEXT: *(u8 *)(r5 + 0) = w0
; CHECK-NEXT: r4 += 1
; CHECK-NEXT: if r4 < r3 goto LBB0_2
; CHECK-NEXT: .Ltmp7:
; CHECK-NEXT: .Ltmp8:
; CHECK-NEXT: LBB0_3: # %post-loop-memcpy-expansion
; CHECK-NEXT: #DEBUG_VALUE: warn:dst <- $r6
; CHECK-NEXT: #DEBUG_VALUE: warn:len <- $r3
; CHECK-NEXT: #DEBUG_VALUE: warn:src <- $r2
; CHECK-NEXT: .loc 1 7 2 is_stmt 1 # warn_call.c:7:2
; CHECK-NEXT: .Ltmp9:
; CHECK-NEXT: r1 = r6
; CHECK-NEXT: call foo
; CHECK-NEXT: .Ltmp10:
; CHECK-NEXT: .Ltmp11:
; CHECK-NEXT: .loc 1 8 9 # warn_call.c:8:9
; CHECK-NEXT: .Ltmp12:
; CHECK-NEXT: r1 = r6
; CHECK-NEXT: call bar
; CHECK-NEXT: .loc 1 8 2 is_stmt 0 # warn_call.c:8:2
; CHECK-NEXT: .Ltmp13:
; CHECK-NEXT: exit
; CHECK-NEXT: .Ltmp14:
; CHECK-NEXT: .Ltmp15:
tail call void @llvm.dbg.value(metadata ptr %0, i64 0, metadata !14, metadata !17), !dbg !18
tail call void @llvm.dbg.value(metadata ptr %1, i64 0, metadata !15, metadata !17), !dbg !19
tail call void @llvm.dbg.value(metadata i64 %2, i64 0, metadata !16, metadata !17), !dbg !20
Expand All @@ -19,6 +78,21 @@ declare ptr @foo(ptr, ptr, i64) local_unnamed_addr #2

; Function Attrs: noinline nounwind readnone
define internal fastcc ptr @bar(ptr readnone returned) unnamed_addr #3 !dbg !25 {
; CHECK-LABEL: bar:
; CHECK: .Lfunc_begin1:
; CHECK-NEXT: .loc 1 2 0 is_stmt 1 # warn_call.c:2:0
; CHECK-NEXT: .cfi_startproc
; CHECK-NEXT: # %bb.0:
; CHECK-NEXT: r0 = r1
; CHECK-NEXT: #DEBUG_VALUE: bar:src <- 0
; CHECK-NEXT: #DEBUG_VALUE: bar:len <- 0
; CHECK-NEXT: .Ltmp16:
; CHECK-NEXT: .loc 1 2 93 prologue_end # warn_call.c:2:93
; CHECK-NEXT: .Ltmp17:
; CHECK-NEXT: .Ltmp18:
; CHECK-NEXT: exit
; CHECK-NEXT: .Ltmp19:
; CHECK-NEXT: .Ltmp20:
tail call void @llvm.dbg.value(metadata ptr null, i64 0, metadata !28, metadata !17), !dbg !30
tail call void @llvm.dbg.value(metadata i64 0, i64 0, metadata !29, metadata !17), !dbg !31
ret ptr %0, !dbg !32
Expand Down