Re: [PATCH bpf-next 1/3] bpf: Propagate scalar ranges through register assignments.

2020-10-08 Thread Alexei Starovoitov
On Thu, Oct 08, 2020 at 08:18:46AM -0700, John Fastabend wrote: > > > > I couldn't think of any other case where scalar's ID has to be cleared. > > Any kind of assignment and r0 return do it as well. > > How about a zero extending move? > > r1 = r2 <- r1.id = r2.id > w1 = w1 > > that will nar

Re: [PATCH bpf-next 1/3] bpf: Propagate scalar ranges through register assignments.

2020-10-08 Thread John Fastabend
Alexei Starovoitov wrote: > On Wed, Oct 07, 2020 at 04:55:24PM -0700, John Fastabend wrote: > > John Fastabend wrote: > > > Alexei Starovoitov wrote: > > > > From: Alexei Starovoitov > > > > > > > > The llvm register allocator may use two different registers > > > > representing the > > > > same

Re: [PATCH bpf-next 1/3] bpf: Propagate scalar ranges through register assignments.

2020-10-07 Thread Alexei Starovoitov
On Wed, Oct 07, 2020 at 04:55:24PM -0700, John Fastabend wrote: > John Fastabend wrote: > > Alexei Starovoitov wrote: > > > From: Alexei Starovoitov > > > > > > The llvm register allocator may use two different registers representing > > > the > > > same virtual register. In such case the follow

RE: [PATCH bpf-next 1/3] bpf: Propagate scalar ranges through register assignments.

2020-10-07 Thread John Fastabend
John Fastabend wrote: > Alexei Starovoitov wrote: > > From: Alexei Starovoitov > > > > The llvm register allocator may use two different registers representing the > > same virtual register. In such case the following pattern can be observed: > > 1047: (bf) r9 = r6 > > 1048: (a5) if r6 < 0x1000 g

RE: [PATCH bpf-next 1/3] bpf: Propagate scalar ranges through register assignments.

2020-10-07 Thread John Fastabend
Alexei Starovoitov wrote: > From: Alexei Starovoitov > > The llvm register allocator may use two different registers representing the > same virtual register. In such case the following pattern can be observed: > 1047: (bf) r9 = r6 > 1048: (a5) if r6 < 0x1000 goto pc+1 > 1050: ... > 1051: (a5) if

Re: [PATCH bpf-next 1/3] bpf: Propagate scalar ranges through register assignments.

2020-10-06 Thread Alexei Starovoitov
On Tue, Oct 06, 2020 at 09:42:18PM -0700, Andrii Nakryiko wrote: > > I see it differently. > > I don't like moving if (reg->id) into find_equal_scalars(). Otherwise it > > would > > have to be named something like try_find_equal_scalars(). And even with such > > "try_" prefix it's still not clean.

Re: [PATCH bpf-next 1/3] bpf: Propagate scalar ranges through register assignments.

2020-10-06 Thread Andrii Nakryiko
On Tue, Oct 6, 2020 at 9:15 PM Alexei Starovoitov wrote: > > On Tue, Oct 06, 2020 at 08:31:23PM -0700, Andrii Nakryiko wrote: > > > > > 'linked' is also wrong. The regs are exactly equal. > > > In case of pkt and other pointers two regs will have the same id > > > as well, but they will not be equ

Re: [PATCH bpf-next 1/3] bpf: Propagate scalar ranges through register assignments.

2020-10-06 Thread Alexei Starovoitov
On Tue, Oct 06, 2020 at 08:31:23PM -0700, Andrii Nakryiko wrote: > > > 'linked' is also wrong. The regs are exactly equal. > > In case of pkt and other pointers two regs will have the same id > > as well, but they will not be equal. Here these two scalars are equal > > otherwise doing *reg = *know

Re: [PATCH bpf-next 1/3] bpf: Propagate scalar ranges through register assignments.

2020-10-06 Thread Andrii Nakryiko
On Tue, Oct 6, 2020 at 7:18 PM Alexei Starovoitov wrote: > > On Tue, Oct 06, 2020 at 06:56:14PM -0700, Andrii Nakryiko wrote: > > On Tue, Oct 6, 2020 at 1:14 PM Alexei Starovoitov > > wrote: > > > > > > From: Alexei Starovoitov > > > > > > The llvm register allocator may use two different regist

Re: [PATCH bpf-next 1/3] bpf: Propagate scalar ranges through register assignments.

2020-10-06 Thread Alexei Starovoitov
On Tue, Oct 06, 2020 at 06:56:14PM -0700, Andrii Nakryiko wrote: > On Tue, Oct 6, 2020 at 1:14 PM Alexei Starovoitov > wrote: > > > > From: Alexei Starovoitov > > > > The llvm register allocator may use two different registers representing the > > same virtual register. In such case the following

Re: [PATCH bpf-next 1/3] bpf: Propagate scalar ranges through register assignments.

2020-10-06 Thread Andrii Nakryiko
On Tue, Oct 6, 2020 at 1:14 PM Alexei Starovoitov wrote: > > From: Alexei Starovoitov > > The llvm register allocator may use two different registers representing the > same virtual register. In such case the following pattern can be observed: > 1047: (bf) r9 = r6 > 1048: (a5) if r6 < 0x1000 goto

[PATCH bpf-next 1/3] bpf: Propagate scalar ranges through register assignments.

2020-10-06 Thread Alexei Starovoitov
From: Alexei Starovoitov The llvm register allocator may use two different registers representing the same virtual register. In such case the following pattern can be observed: 1047: (bf) r9 = r6 1048: (a5) if r6 < 0x1000 goto pc+1 1050: ... 1051: (a5) if r9 < 0x2 goto pc+66 1052: ... 1053: (bf)