|
| 1 | +; RUN: llc < %s -march=bpf -verify-machineinstrs | FileCheck %s |
| 2 | +; Source Code: |
| 3 | +; struct loc_prog { |
| 4 | +; unsigned int ip; |
| 5 | +; int len; |
| 6 | +; }; |
| 7 | +; int exec_prog(struct loc_prog *prog) { |
| 8 | +; if (prog->ip < prog->len) { |
| 9 | +; int x = prog->ip; |
| 10 | +; if (x < 3) |
| 11 | +; prog->ip += 2; |
| 12 | +; } |
| 13 | +; return 3; |
| 14 | +; } |
| 15 | +; Compilation flag: |
| 16 | +; clang -target bpf -O2 -S -emit-llvm t.c |
| 17 | + |
| 18 | +%struct.loc_prog = type { i32, i32 } |
| 19 | + |
| 20 | +; Function Attrs: nofree norecurse nounwind willreturn |
| 21 | +define dso_local i32 @exec_prog(%struct.loc_prog* nocapture %prog) local_unnamed_addr { |
| 22 | +entry: |
| 23 | + %ip = getelementptr inbounds %struct.loc_prog, %struct.loc_prog* %prog, i64 0, i32 0 |
| 24 | + %0 = load i32, i32* %ip, align 4 |
| 25 | + %len = getelementptr inbounds %struct.loc_prog, %struct.loc_prog* %prog, i64 0, i32 1 |
| 26 | + %1 = load i32, i32* %len, align 4 |
| 27 | + %cmp = icmp ult i32 %0, %1 |
| 28 | + %cmp2 = icmp slt i32 %0, 3 |
| 29 | + %or.cond = and i1 %cmp2, %cmp |
| 30 | +; CHECK: r{{[0-9]+}} <<= 32 |
| 31 | +; CHECK: r{{[0-9]+}} s>>= 32 |
| 32 | + br i1 %or.cond, label %if.then3, label %if.end5 |
| 33 | + |
| 34 | +if.then3: ; preds = %entry |
| 35 | + %add = add nsw i32 %0, 2 |
| 36 | + store i32 %add, i32* %ip, align 4 |
| 37 | + br label %if.end5 |
| 38 | + |
| 39 | +if.end5: ; preds = %if.then3, %entry |
| 40 | + ret i32 3 |
| 41 | +} |
0 commit comments