1; RUN: llc < %s -march=bpf -verify-machineinstrs | FileCheck %s 2 3; Source code: 4; struct xdp_md { 5; unsigned data; 6; unsigned data_end; 7; }; 8; 9; int gbl; 10; int xdp_dummy(struct xdp_md *xdp) 11; { 12; char tmp; 13; long addr; 14; 15; if (gbl) { 16; long addr1 = (long)xdp->data; 17; tmp = *(char *)addr1; 18; if (tmp == 1) 19; return 3; 20; } else { 21; tmp = *(volatile char *)(long)xdp->data_end; 22; if (tmp == 1) 23; return 2; 24; } 25; addr = (long)xdp->data; 26; tmp = *(volatile char *)addr; 27; if (tmp == 0) 28; return 1; 29; return 0; 30; } 31 32%struct.xdp_md = type { i32, i32 } 33 34@gbl = common local_unnamed_addr global i32 0, align 4 35 36; Function Attrs: norecurse nounwind 37define i32 @xdp_dummy(%struct.xdp_md* nocapture readonly %xdp) local_unnamed_addr #0 { 38entry: 39 %0 = load i32, i32* @gbl, align 4 40 %tobool = icmp eq i32 %0, 0 41 br i1 %tobool, label %if.else, label %if.then 42 43if.then: ; preds = %entry 44 %data = getelementptr inbounds %struct.xdp_md, %struct.xdp_md* %xdp, i64 0, i32 0 45 %1 = load i32, i32* %data, align 4 46 %conv = zext i32 %1 to i64 47 %2 = inttoptr i64 %conv to i8* 48 %3 = load i8, i8* %2, align 1 49 %cmp = icmp eq i8 %3, 1 50 br i1 %cmp, label %cleanup20, label %if.end12 51; CHECK: r1 = *(u32 *)(r1 + 0) 52; CHECK: r2 = *(u8 *)(r1 + 0) 53 54if.else: ; preds = %entry 55 %data_end = getelementptr inbounds %struct.xdp_md, %struct.xdp_md* %xdp, i64 0, i32 1 56 %4 = load i32, i32* %data_end, align 4 57 %conv6 = zext i32 %4 to i64 58; CHECK: r2 = *(u32 *)(r1 + 4) 59 %5 = inttoptr i64 %conv6 to i8* 60 %6 = load volatile i8, i8* %5, align 1 61 %cmp8 = icmp eq i8 %6, 1 62 br i1 %cmp8, label %cleanup20, label %if.else.if.end12_crit_edge 63 64if.else.if.end12_crit_edge: ; preds = %if.else 65 %data13.phi.trans.insert = getelementptr inbounds %struct.xdp_md, %struct.xdp_md* %xdp, i64 0, i32 0 66 %.pre = load i32, i32* %data13.phi.trans.insert, align 4 67 br label %if.end12 68; CHECK: r1 = *(u32 *)(r1 + 0) 69 70if.end12: ; preds = %if.else.if.end12_crit_edge, %if.then 71 %7 = phi i32 [ %.pre, %if.else.if.end12_crit_edge ], [ %1, %if.then ] 72 %conv14 = zext i32 %7 to i64 73; CHECK-NOT: r1 <<= 32 74; CHECK-NOT: r1 >>= 32 75 %8 = inttoptr i64 %conv14 to i8* 76 %9 = load volatile i8, i8* %8, align 1 77; CHECK: r1 = *(u8 *)(r1 + 0) 78 %cmp16 = icmp eq i8 %9, 0 79 %.28 = zext i1 %cmp16 to i32 80 br label %cleanup20 81 82cleanup20: ; preds = %if.then, %if.end12, %if.else 83 %retval.1 = phi i32 [ 3, %if.then ], [ 2, %if.else ], [ %.28, %if.end12 ] 84 ret i32 %retval.1 85} 86 87attributes #0 = { norecurse nounwind } 88