From: Yonghong Song Date: Mon, 20 Nov 2017 21:37:58 +0000 (+0000) Subject: bpf: add a test case for trunc-op optimization X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a4de6d86db7556f27584497f67b34a565eca630a;p=platform%2Fupstream%2Fllvm.git bpf: add a test case for trunc-op optimization Commit b5cbc7760ab8 ("[bpf] allow direct and indirect calls") allowed more than one function in the bpf program, and commit 114353884415 ("bpf: fix a bug in trunc-op optimization") fixed a bug in trunc-op optimization which only showed up with more than one function in the bpf program. This patch added a test case for trunc-op optimization for bpf programs with two functions. Reverting commit "bpf: fix a bug in trunc-op optimization" will cause failure for this test case. Signed-off-by: Yonghong Song llvm-svn: 318695 --- diff --git a/llvm/test/CodeGen/BPF/remove_truncate_3.ll b/llvm/test/CodeGen/BPF/remove_truncate_3.ll new file mode 100644 index 0000000..4e58b5e --- /dev/null +++ b/llvm/test/CodeGen/BPF/remove_truncate_3.ll @@ -0,0 +1,106 @@ +; RUN: llc < %s -march=bpf -verify-machineinstrs | FileCheck %s + +; Source code: +; struct xdp_md { +; unsigned data; +; unsigned data_end; +; }; +; +; int gbl; +; int xdp_dummy(struct xdp_md *xdp) +; { +; char tmp; +; long addr; +; +; if (gbl) { +; long addr1 = (long)xdp->data; +; tmp = *(char *)addr1; +; if (tmp == 1) +; return 3; +; } else { +; tmp = *(volatile char *)(long)xdp->data_end; +; if (tmp == 1) +; return 2; +; } +; addr = (long)xdp->data; +; tmp = *(volatile char *)addr; +; if (tmp == 0) +; return 1; +; return 0; +; } +; +; unsigned int rol32(unsigned int word, unsigned int shift) +; { +; return (word << shift) | (word >> ((-shift) & 31)); +; } +%struct.xdp_md = type { i32, i32 } + +@gbl = common local_unnamed_addr global i32 0, align 4 + +; Function Attrs: norecurse nounwind +define i32 @xdp_dummy(%struct.xdp_md* nocapture readonly) local_unnamed_addr #0 { + %2 = load i32, i32* @gbl, align 4 + %3 = icmp eq i32 %2, 0 + br i1 %3, label %11, label %4 + +;