Open socketpair opened 1 year ago
I think this was fixed by the following commit: 651e644595b72c22fd22f51358cf083146790ed4
The <<= >>= pair is zero extension, before that commit compiler was not aware that zero extension of 32-bit load is always free.
The empty jump is an artifact of inline assembly usage: if (ip->protocol) __asm__("" ::: "memory");
:
if
is translated as a conditional jump and a new basic block (label);__asm__("r9=r9;" ::: "memory");
and observing the change.The example as compiled by current clang:
$ clang --target=bpf -mcpu=v2 -O2 t.c -c -o - | llvm-objdump --no-show-raw-insn -d -
<stdin>: file format elf64-bpf
Disassembly of section .text:
0000000000000000 <some_fun>:
0: r2 = *(u32 *)(r1 + 0x4)
1: r1 = *(u32 *)(r1 + 0x0)
2: if r1 == 0x0 goto +0x0 <LBB0_2>
0000000000000018 <LBB0_2>:
3: r0 = 0x1
4: if r2 == 0xab4130 goto +0x1 <LBB0_4>
5: r0 = 0x0
0000000000000030 <LBB0_4>:
6: exit
0000000000000038 <some_fun_2>:
7: r1 = *(u32 *)(r1 + 0x4)
8: r0 = 0x1
9: if r1 == 0xab4130 goto +0x1 <LBB1_2>
10: r0 = 0x0
0000000000000058 <LBB1_2>:
11: exit
0000000000000060 <some_fun_3>:
12: r2 = *(u32 *)(r1 + 0x4)
13: r1 = *(u32 *)(r1 + 0x0)
14: if r1 == 0x0 goto +0x0 <LBB2_2>
0000000000000078 <LBB2_2>:
15: r0 = 0x1
16: if r2 == 0xab4130 goto +0x1 <LBB2_4>
17: r0 = 0x0
0000000000000090 <LBB2_4>:
18: exit
https://godbolt.org/z/ProhnxfTv
-target bpf -mcpu=v2 -O3