[llvm-bugs] [Bug 33369] New: BPF target: code generation with shifts around ptr types
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Jun 8 13:56:40 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=33369
Bug ID: 33369
Summary: BPF target: code generation with shifts around ptr
types
Product: new-bugs
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: unassignedbugs at nondot.org
Reporter: daniel at iogearbox.net
CC: llvm-bugs at lists.llvm.org
We've seen code generated for the BPF ctx (XDP in this case) that looks as
follows:
[...]
; new_dst.p4 |= svc->rev_nat_index;
704: r3 <<= 8
705: r3 |= r4
; if (svc->rev_nat_index)
706: r2 |= r3
; memcpy(ptr, from, len);
707: *(u8 *)(r1 + 50) = r2
708: r2 >>= 8
709: *(u8 *)(r1 + 51) = r2
710: r2 = *(u32 *)(r6 + 4) ; XDP data_end (rewrite to ptr load)
711: r1 = *(u32 *)(r6 + 0) ; XDP data (rewrite to ptr load)
LBB0_107:
712: r3 = 4294967142ll
; void *end = (void *)(long) xdp->data_end;
714: r2 <<= 32 ; buggy (destroys ptr)
715: r2 >>= 32 ; buggy
; void *data = (void *)(long) xdp->data;
716: r1 <<= 32 ; buggy (destroys ptr)
717: r1 >>= 32 ; buggy
; if (data + sizeof(*ptr) > end)
718: r4 = r1
719: r4 += 2
720: if r4 > r2 goto 3
; *(__u16 *) data = 1;//csum;
721: r2 = 1
722: *(u16 *)(r1 + 0) = r2
723: r3 = 0
[...]
$ clang --version
clang version 5.0.0 (https://github.com/llvm-mirror/clang.git
91d84ed65dd3629b4536cf393850ecfdfd3f1be5)
(https://github.com/llvm-mirror/llvm.git
2385754c5e1ce0689b4295a3e13e1a47215b850d)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170608/e24c1c1d/attachment.html>
More information about the llvm-bugs
mailing list