57 lines · plain
1; RUN: llc < %s -mtriple=bpf -verify-machineinstrs | FileCheck %s2 3; Source code:4;struct __sk_buff;5;unsigned long long6;load_byte(ptr skb, unsigned long long off) asm("llvm.bpf.load.byte");7;unsigned long long8;load_half(ptr skb, unsigned long long off) asm("llvm.bpf.load.half");9;typedef unsigned char uint8_t;10;typedef unsigned short uint16_t;11;12;int func_b(struct __sk_buff *skb)13;{14; uint8_t t = load_byte(skb, 0);15; return t;16;}17;18;int func_h(struct __sk_buff *skb)19;{20; uint16_t t = load_half(skb, 0);21; return t;22;}23;24;int func_w(struct __sk_buff *skb)25;{26; uint32_t t = load_word(skb, 0);27; return t;28;}29 30%struct.__sk_buff = type opaque31 32; Function Attrs: nounwind readonly33define i32 @func_b(ptr %skb) local_unnamed_addr #0 {34entry:35 %call = tail call i64 @llvm.bpf.load.byte(ptr %skb, i64 0)36 %conv = trunc i64 %call to i3237 %conv1 = and i32 %conv, 25538; CHECK-NOT: r0 &= 25539 ret i32 %conv140}41 42; Function Attrs: nounwind readonly43declare i64 @llvm.bpf.load.byte(ptr, i64) #144 45; Function Attrs: nounwind readonly46define i32 @func_h(ptr %skb) local_unnamed_addr #0 {47entry:48 %call = tail call i64 @llvm.bpf.load.half(ptr %skb, i64 0)49 %conv = trunc i64 %call to i3250 %conv1 = and i32 %conv, 6553551; CHECK-NOT: r0 &= 6553552 ret i32 %conv153}54 55; Function Attrs: nounwind readonly56declare i64 @llvm.bpf.load.half(ptr, i64) #157