<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - BPF target: relocation records generated for calculations on constants"
href="https://bugs.llvm.org/show_bug.cgi?id=33599">33599</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>BPF target: relocation records generated for calculations on constants
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>3.8
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>daniel@iogearbox.net
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>cilium bug id: <a href="https://github.com/cilium/cilium/issues/1033">https://github.com/cilium/cilium/issues/1033</a>
llc --version
llc: /lib64/libtinfo.so.5: no version information available (required by llc)
LLVM (<a href="http://llvm.org/">http://llvm.org/</a>):
LLVM version 3.8.1
Optimized build.
Default target: x86_64-unknown-linux-gnu
Host CPU: skylake
Registered Targets:
[...]
bpf - BPF (host endian)
bpfeb - BPF (big endian)
bpfel - BPF (little endian)
[...]
No issue with following code:
static inline struct endpoint_info *__inline__ lookup_ip4_endpoint(struct iphdr
*ip4)
{
struct endpoint_key key = { };
key.ip4 = bpf_ntohl(42);
return map_lookup_elem(&cilium_lxc, &key);
}
Issue with that one:
static inline struct endpoint_info *__inline__ lookup_ip4_endpoint(struct iphdr
*ip4)
{
struct endpoint_key key = {
.ip4 = bpf_ntohl(42);
};
return map_lookup_elem(&cilium_lxc, &key);
}
bpf_ntohl() implementation in both cases is at:
<a href="https://github.com/cilium/cilium/blob/master/bpf/lib/utils.h">https://github.com/cilium/cilium/blob/master/bpf/lib/utils.h</a>
LLVM generates an invalid reloc entry from BPF backend for the problematic
lookup_ip4_endpoint(), but it (rightfully) doesn't generate an entry for the
other one.
More details from asm:
[...]
# BB#154:
std -136(r10), r5
ld_64 r1, <MCOperand Expr:(.Llookup_ip4_endpoint.key)>
ldw r2, 0(r1)
ldw r1, 4(r1)
slli r1, 32
or r1, r2
std -56(r10), r1
std -64(r10), r1
mov r2, r10
addi r2, -64
ld_64 r1, <MCOperand Expr:(cilium_lxc)>
call 1
jeqi r0, 0 goto LBB5_305
[...]
.section .rodata.cst16,"aM",@progbits,16
.align 4 # @lookup_ip4_endpoint.key
.Llookup_ip4_endpoint.key:
.long 704643072 # 0x2a000000
.zero 12
I would also have though that given this is all ops based on constants, that
LLVM optimizes all of this away and just performs the load of the final
constant.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>