1; RUN: llc < %s -mtriple=bpf -verify-machineinstrs | FileCheck %s 2 3; Source code: 4;struct __sk_buff; 5;unsigned long long 6;load_byte(ptr skb, unsigned long long off) asm("llvm.bpf.load.byte"); 7;unsigned long long 8;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 opaque 31 32; Function Attrs: nounwind readonly 33define 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 i32 37 %conv1 = and i32 %conv, 255 38; CHECK-NOT: r0 &= 255 39 ret i32 %conv1 40} 41 42; Function Attrs: nounwind readonly 43declare i64 @llvm.bpf.load.byte(ptr, i64) #1 44 45; Function Attrs: nounwind readonly 46define 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 i32 50 %conv1 = and i32 %conv, 65535 51; CHECK-NOT: r0 &= 65535 52 ret i32 %conv1 53} 54 55; Function Attrs: nounwind readonly 56declare i64 @llvm.bpf.load.half(ptr, i64) #1 57