2024-06-12 09:19:56

by kunyu

[permalink] [raw]
Subject: [PATCH] x86: net: bpf_jit_comp32: Remove unused 'cnt' variables from most functions

In these functions, the 'cnt' variable is not used or does not require
value checking, so these 'cnt' variables can be removed.

Signed-off-by: kunyu <[email protected]>
---
arch/x86/net/bpf_jit_comp32.c | 27 ++-------------------------
1 file changed, 2 insertions(+), 25 deletions(-)

diff --git a/arch/x86/net/bpf_jit_comp32.c b/arch/x86/net/bpf_jit_comp32.c
index de0f9e5f9f73..30f9b8a3faed 100644
--- a/arch/x86/net/bpf_jit_comp32.c
+++ b/arch/x86/net/bpf_jit_comp32.c
@@ -207,7 +207,6 @@ static inline void emit_ia32_mov_i(const u8 dst, const u32 val, bool dstk,
u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;

if (dstk) {
if (val == 0) {
@@ -235,7 +234,6 @@ static inline void emit_ia32_mov_r(const u8 dst, const u8 src, bool dstk,
bool sstk, u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;
u8 sreg = sstk ? IA32_EAX : src;

if (sstk)
@@ -286,7 +284,6 @@ static inline void emit_ia32_mul_r(const u8 dst, const u8 src, bool dstk,
bool sstk, u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;
u8 sreg = sstk ? IA32_ECX : src;

if (sstk)
@@ -319,7 +316,6 @@ static inline void emit_ia32_to_le_r64(const u8 dst[], s32 val,
const struct bpf_prog_aux *aux)
{
u8 *prog = *pprog;
- int cnt = 0;
u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
u8 dreg_hi = dstk ? IA32_EDX : dst_hi;

@@ -367,7 +363,6 @@ static inline void emit_ia32_to_be_r64(const u8 dst[], s32 val,
const struct bpf_prog_aux *aux)
{
u8 *prog = *pprog;
- int cnt = 0;
u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
u8 dreg_hi = dstk ? IA32_EDX : dst_hi;

@@ -436,7 +431,6 @@ static inline void emit_ia32_div_mod_r(const u8 op, const u8 dst, const u8 src,
bool dstk, bool sstk, u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;

if (sstk)
/* mov ecx,dword ptr [ebp+off] */
@@ -483,7 +477,6 @@ static inline void emit_ia32_shift_r(const u8 op, const u8 dst, const u8 src,
bool dstk, bool sstk, u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;
u8 dreg = dstk ? IA32_EAX : dst;
u8 b2;

@@ -525,7 +518,6 @@ static inline void emit_ia32_alu_r(const bool is64, const bool hi, const u8 op,
bool sstk, u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;
u8 sreg = sstk ? IA32_EAX : src;
u8 dreg = dstk ? IA32_EDX : dst;

@@ -599,7 +591,6 @@ static inline void emit_ia32_alu_i(const bool is64, const bool hi, const u8 op,
u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;
u8 dreg = dstk ? IA32_EAX : dst;
u8 sreg = IA32_EDX;

@@ -698,7 +689,6 @@ static inline void emit_ia32_alu_i64(const bool is64, const u8 op,
static inline void emit_ia32_neg64(const u8 dst[], bool dstk, u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;
u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
u8 dreg_hi = dstk ? IA32_EDX : dst_hi;

@@ -732,7 +722,6 @@ static inline void emit_ia32_lsh_r64(const u8 dst[], const u8 src[],
bool dstk, bool sstk, u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;
u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
u8 dreg_hi = dstk ? IA32_EDX : dst_hi;

@@ -785,7 +774,6 @@ static inline void emit_ia32_arsh_r64(const u8 dst[], const u8 src[],
bool dstk, bool sstk, u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;
u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
u8 dreg_hi = dstk ? IA32_EDX : dst_hi;

@@ -838,7 +826,6 @@ static inline void emit_ia32_rsh_r64(const u8 dst[], const u8 src[], bool dstk,
bool sstk, u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;
u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
u8 dreg_hi = dstk ? IA32_EDX : dst_hi;

@@ -891,7 +878,6 @@ static inline void emit_ia32_lsh_i64(const u8 dst[], const u32 val,
bool dstk, u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;
u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
u8 dreg_hi = dstk ? IA32_EDX : dst_hi;

@@ -939,7 +925,6 @@ static inline void emit_ia32_rsh_i64(const u8 dst[], const u32 val,
bool dstk, u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;
u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
u8 dreg_hi = dstk ? IA32_EDX : dst_hi;

@@ -988,7 +973,6 @@ static inline void emit_ia32_arsh_i64(const u8 dst[], const u32 val,
bool dstk, u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;
u8 dreg_lo = dstk ? IA32_EAX : dst_lo;
u8 dreg_hi = dstk ? IA32_EDX : dst_hi;

@@ -1036,7 +1020,6 @@ static inline void emit_ia32_mul_r64(const u8 dst[], const u8 src[], bool dstk,
bool sstk, u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;

if (dstk)
/* mov eax,dword ptr [ebp+off] */
@@ -1113,7 +1096,6 @@ static inline void emit_ia32_mul_i64(const u8 dst[], const u32 val,
bool dstk, u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;
u32 hi;

hi = val & (1<<31) ? (u32)~0 : 0;
@@ -1200,7 +1182,6 @@ struct jit_context {
static void emit_prologue(u8 **pprog, u32 stack_depth)
{
u8 *prog = *pprog;
- int cnt = 0;
const u8 *r1 = bpf2ia32[BPF_REG_1];
const u8 fplo = bpf2ia32[BPF_REG_FP][0];
const u8 fphi = bpf2ia32[BPF_REG_FP][1];
@@ -1237,7 +1218,6 @@ static void emit_prologue(u8 **pprog, u32 stack_depth)
EMIT3(0x89, add_2reg(0x40, IA32_EBP, IA32_EBX), STACK_VAR(tcc[0]));
EMIT3(0x89, add_2reg(0x40, IA32_EBP, IA32_EBX), STACK_VAR(tcc[1]));

- BUILD_BUG_ON(cnt != PROLOGUE_SIZE);
*pprog = prog;
}

@@ -1246,7 +1226,6 @@ static void emit_epilogue(u8 **pprog, u32 stack_depth)
{
u8 *prog = *pprog;
const u8 *r0 = bpf2ia32[BPF_REG_0];
- int cnt = 0;

/* mov eax,dword ptr [ebp+off]*/
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX), STACK_VAR(r0[0]));
@@ -1391,7 +1370,6 @@ static void emit_bpf_tail_call(u8 **pprog, u8 *ip)
static inline void emit_push_r64(const u8 src[], u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;

/* mov ecx,dword ptr [ebp+off] */
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_ECX), STACK_VAR(src_hi));
@@ -1409,7 +1387,6 @@ static inline void emit_push_r64(const u8 src[], u8 **pprog)
static void emit_push_r32(const u8 src[], u8 **pprog)
{
u8 *prog = *pprog;
- int cnt = 0;

/* mov ecx,dword ptr [ebp+off] */
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_ECX), STACK_VAR(src_lo));
@@ -1570,7 +1547,7 @@ static int emit_kfunc_call(const struct bpf_prog *bpf_prog, u8 *end_addr,
const struct bpf_insn *insn, u8 **pprog)
{
const u8 arg_regs[] = { IA32_EAX, IA32_EDX, IA32_ECX };
- int i, cnt = 0, first_stack_regno, last_stack_regno;
+ int i, first_stack_regno, last_stack_regno;
int free_arg_regs = ARRAY_SIZE(arg_regs);
const struct btf_func_model *fm;
int bytes_in_stack = 0;
@@ -1663,7 +1640,7 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image,
int insn_cnt = bpf_prog->len;
bool seen_exit = false;
u8 temp[BPF_MAX_INSN_SIZE + BPF_INSN_SAFETY];
- int i, cnt = 0;
+ int i;
int proglen = 0;
u8 *prog = temp;

--
2.18.2



2024-06-12 18:08:15

by Alexei Starovoitov

[permalink] [raw]
Subject: Re: [PATCH] x86: net: bpf_jit_comp32: Remove unused 'cnt' variables from most functions

On Wed, Jun 12, 2024 at 1:59 AM kunyu <[email protected]> wrote:
>
> In these functions, the 'cnt' variable is not used or does not require
> value checking, so these 'cnt' variables can be removed.
>
> Signed-off-by: kunyu <[email protected]>
> ---
> arch/x86/net/bpf_jit_comp32.c | 27 ++-------------------------
> 1 file changed, 2 insertions(+), 25 deletions(-)
>
> diff --git a/arch/x86/net/bpf_jit_comp32.c b/arch/x86/net/bpf_jit_comp32.c
> index de0f9e5f9f73..30f9b8a3faed 100644
> --- a/arch/x86/net/bpf_jit_comp32.c
> +++ b/arch/x86/net/bpf_jit_comp32.c
> @@ -207,7 +207,6 @@ static inline void emit_ia32_mov_i(const u8 dst, const u32 val, bool dstk,
> u8 **pprog)
> {
> u8 *prog = *pprog;
> - int cnt = 0;

I don't think you bothered to compile it.

pw-bot: cr

2024-06-13 00:38:57

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] x86: net: bpf_jit_comp32: Remove unused 'cnt' variables from most functions

Hi kunyu,

kernel test robot noticed the following build errors:

[auto build test ERROR on bpf-next/master]
[also build test ERROR on bpf/master net-next/main net/main linus/master v6.10-rc3 next-20240612]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/kunyu/x86-net-bpf_jit_comp32-Remove-unused-cnt-variables-from-most-functions/20240612-170017
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link: https://lore.kernel.org/r/20240612085823.28133-1-kunyu%40nfschina.com
patch subject: [PATCH] x86: net: bpf_jit_comp32: Remove unused 'cnt' variables from most functions
config: i386-buildonly-randconfig-005-20240613 (https://download.01.org/0day-ci/archive/20240613/[email protected]/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240613/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_mov_i':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:68:24: note: in expansion of macro 'EMIT'
#define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
^~~~
arch/x86/net/bpf_jit_comp32.c:214:4: note: in expansion of macro 'EMIT2'
EMIT2(0x33, add_2reg(0xC0, IA32_EAX, IA32_EAX));
^~~~~
arch/x86/net/bpf_jit_comp32.c:65:43: note: each undeclared identifier is reported only once for each function it appears in
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:68:24: note: in expansion of macro 'EMIT'
#define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
^~~~
arch/x86/net/bpf_jit_comp32.c:214:4: note: in expansion of macro 'EMIT2'
EMIT2(0x33, add_2reg(0xC0, IA32_EAX, IA32_EAX));
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_mov_r':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:241:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX), STACK_VAR(src));
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_mul_r':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:291:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_ECX), STACK_VAR(src));
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_to_le_r64':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:323:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX),
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_to_be_r64':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:370:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX),
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_div_mod_r':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:437:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_ECX),
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_shift_r':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:485:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX), STACK_VAR(dst));
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_alu_r':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:526:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX), STACK_VAR(src));
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_alu_i':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:599:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX), STACK_VAR(dst));
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_neg64':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:696:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX),
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_lsh_r64':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:729:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX),
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_arsh_r64':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:781:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX),
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_rsh_r64':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:833:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX),
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_lsh_i64':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:885:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX),
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_rsh_i64':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:932:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX),
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_arsh_i64':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:980:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX),
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_mul_r64':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:1026:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX),
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_ia32_mul_i64':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:68:24: note: in expansion of macro 'EMIT'
#define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
^~~~
arch/x86/net/bpf_jit_comp32.c:76:7: note: in expansion of macro 'EMIT2'
do { EMIT2(b1, b2); EMIT(off, 4); } while (0)
^~~~~
arch/x86/net/bpf_jit_comp32.c:1103:2: note: in expansion of macro 'EMIT2_off32'
EMIT2_off32(0xC7, add_1reg(0xC0, IA32_EAX), val);
^~~~~~~~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_prologue':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:67:20: note: in expansion of macro 'EMIT'
#define EMIT1(b1) EMIT(b1, 1)
^~~~
arch/x86/net/bpf_jit_comp32.c:1191:2: note: in expansion of macro 'EMIT1'
EMIT1(0x55);
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_epilogue':
>> arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:1231:2: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX), STACK_VAR(r0[0]));
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_push_r64':
arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:1375:2: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_ECX), STACK_VAR(src_hi));
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_push_r32':
arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:1392:2: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_ECX), STACK_VAR(src_lo));
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'emit_kfunc_call':
arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:69:27: note: in expansion of macro 'EMIT'
#define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
^~~~
arch/x86/net/bpf_jit_comp32.c:1588:3: note: in expansion of macro 'EMIT3'
EMIT3(0x8B, add_2reg(0x40, IA32_EBP, *cur_arg_reg++),
^~~~~
arch/x86/net/bpf_jit_comp32.c: In function 'do_jit':
arch/x86/net/bpf_jit_comp32.c:65:43: error: 'cnt' undeclared (first use in this function); did you mean 'int'?
do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
^
arch/x86/net/bpf_jit_comp32.c:68:24: note: in expansion of macro 'EMIT'
#define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
^~~~
arch/x86/net/bpf_jit_comp32.c:76:7: note: in expansion of macro 'EMIT2'
do { EMIT2(b1, b2); EMIT(off, 4); } while (0)
^~~~~
arch/x86/net/bpf_jit_comp32.c:1737:5: note: in expansion of macro 'EMIT2_off32'
EMIT2_off32(0xC7, add_1reg(0xC0, IA32_ECX),
^~~~~~~~~~~


vim +65 arch/x86/net/bpf_jit_comp32.c

03f5781be2c7b7 Wang YanQing 2018-05-03 63
03f5781be2c7b7 Wang YanQing 2018-05-03 64 #define EMIT(bytes, len) \
03f5781be2c7b7 Wang YanQing 2018-05-03 @65 do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
03f5781be2c7b7 Wang YanQing 2018-05-03 66

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2024-06-13 02:17:52

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] x86: net: bpf_jit_comp32: Remove unused 'cnt' variables from most functions

Hi kunyu,

kernel test robot noticed the following build errors:

[auto build test ERROR on bpf-next/master]
[also build test ERROR on bpf/master net-next/main net/main linus/master v6.10-rc3 next-20240612]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/kunyu/x86-net-bpf_jit_comp32-Remove-unused-cnt-variables-from-most-functions/20240612-170017
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link: https://lore.kernel.org/r/20240612085823.28133-1-kunyu%40nfschina.com
patch subject: [PATCH] x86: net: bpf_jit_comp32: Remove unused 'cnt' variables from most functions
config: i386-buildonly-randconfig-004-20240613 (https://download.01.org/0day-ci/archive/20240613/[email protected]/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240613/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

>> arch/x86/net/bpf_jit_comp32.c:214:4: error: use of undeclared identifier 'cnt'
214 | EMIT2(0x33, add_2reg(0xC0, IA32_EAX, IA32_EAX));
| ^
arch/x86/net/bpf_jit_comp32.c:68:24: note: expanded from macro 'EMIT2'
68 | #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
| ^
arch/x86/net/bpf_jit_comp32.c:65:43: note: expanded from macro 'EMIT'
65 | do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
| ^
arch/x86/net/bpf_jit_comp32.c:216:4: error: use of undeclared identifier 'cnt'
216 | EMIT3(0x89, add_2reg(0x40, IA32_EBP, IA32_EAX),
| ^
arch/x86/net/bpf_jit_comp32.c:69:27: note: expanded from macro 'EMIT3'
69 | #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
| ^
arch/x86/net/bpf_jit_comp32.c:65:43: note: expanded from macro 'EMIT'
65 | do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
| ^
arch/x86/net/bpf_jit_comp32.c:219:4: error: use of undeclared identifier 'cnt'
219 | EMIT3_off32(0xC7, add_1reg(0x40, IA32_EBP),
| ^
arch/x86/net/bpf_jit_comp32.c:78:7: note: expanded from macro 'EMIT3_off32'
78 | do { EMIT3(b1, b2, b3); EMIT(off, 4); } while (0)
| ^
arch/x86/net/bpf_jit_comp32.c:69:27: note: expanded from macro 'EMIT3'
69 | #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
| ^
arch/x86/net/bpf_jit_comp32.c:65:43: note: expanded from macro 'EMIT'
65 | do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
| ^
arch/x86/net/bpf_jit_comp32.c:219:4: error: use of undeclared identifier 'cnt'
arch/x86/net/bpf_jit_comp32.c:78:26: note: expanded from macro 'EMIT3_off32'
78 | do { EMIT3(b1, b2, b3); EMIT(off, 4); } while (0)
| ^
arch/x86/net/bpf_jit_comp32.c:65:43: note: expanded from macro 'EMIT'
65 | do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
| ^
arch/x86/net/bpf_jit_comp32.c:224:4: error: use of undeclared identifier 'cnt'
224 | EMIT2(0x33, add_2reg(0xC0, dst, dst));
| ^
arch/x86/net/bpf_jit_comp32.c:68:24: note: expanded from macro 'EMIT2'
68 | #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
| ^
arch/x86/net/bpf_jit_comp32.c:65:43: note: expanded from macro 'EMIT'
65 | do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
| ^
arch/x86/net/bpf_jit_comp32.c:226:4: error: use of undeclared identifier 'cnt'
226 | EMIT2_off32(0xC7, add_1reg(0xC0, dst),
| ^
arch/x86/net/bpf_jit_comp32.c:76:7: note: expanded from macro 'EMIT2_off32'
76 | do { EMIT2(b1, b2); EMIT(off, 4); } while (0)
| ^
arch/x86/net/bpf_jit_comp32.c:68:24: note: expanded from macro 'EMIT2'
68 | #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
| ^
arch/x86/net/bpf_jit_comp32.c:65:43: note: expanded from macro 'EMIT'
65 | do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
| ^
arch/x86/net/bpf_jit_comp32.c:226:4: error: use of undeclared identifier 'cnt'
arch/x86/net/bpf_jit_comp32.c:76:22: note: expanded from macro 'EMIT2_off32'
76 | do { EMIT2(b1, b2); EMIT(off, 4); } while (0)
| ^
arch/x86/net/bpf_jit_comp32.c:65:43: note: expanded from macro 'EMIT'
65 | do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
| ^
arch/x86/net/bpf_jit_comp32.c:241:3: error: use of undeclared identifier 'cnt'
241 | EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_EAX), STACK_VAR(src));
| ^
arch/x86/net/bpf_jit_comp32.c:69:27: note: expanded from macro 'EMIT3'
69 | #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
| ^
arch/x86/net/bpf_jit_comp32.c:65:43: note: expanded from macro 'EMIT'
65 | do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
| ^
arch/x86/net/bpf_jit_comp32.c:244:3: error: use of undeclared identifier 'cnt'
244 | EMIT3(0x89, add_2reg(0x40, IA32_EBP, sreg), STACK_VAR(dst));
| ^
arch/x86/net/bpf_jit_comp32.c:69:27: note: expanded from macro 'EMIT3'
69 | #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
| ^
arch/x86/net/bpf_jit_comp32.c:65:43: note: expanded from macro 'EMIT'
65 | do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
| ^
arch/x86/net/bpf_jit_comp32.c:247:3: error: use of undeclared identifier 'cnt'
247 | EMIT2(0x89, add_2reg(0xC0, dst, sreg));
| ^
arch/x86/net/bpf_jit_comp32.c:68:24: note: expanded from macro 'EMIT2'
68 | #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
| ^
arch/x86/net/bpf_jit_comp32.c:65:43: note: expanded from macro 'EMIT'
65 | do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
| ^
arch/x86/net/bpf_jit_comp32.c:291:3: error: use of undeclared identifier 'cnt'
291 | EMIT3(0x8B, add_2reg(0x40, IA32_EBP, IA32_ECX), STACK_VAR(src));
| ^
arch/x86/net/bpf_jit_comp32.c:69:27: note: expanded from macro 'EMIT3'
69 | #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
| ^
arch/x86/net/bpf_jit_comp32.c:65:43: note: expanded from macro 'EMIT'
65 | do { prog = emit_code(prog, bytes, len); cnt += len; } while (0)
| ^


vim +/cnt +214 arch/x86/net/bpf_jit_comp32.c

03f5781be2c7b7 Wang YanQing 2018-05-03 205
03f5781be2c7b7 Wang YanQing 2018-05-03 206 static inline void emit_ia32_mov_i(const u8 dst, const u32 val, bool dstk,
03f5781be2c7b7 Wang YanQing 2018-05-03 207 u8 **pprog)
03f5781be2c7b7 Wang YanQing 2018-05-03 208 {
03f5781be2c7b7 Wang YanQing 2018-05-03 209 u8 *prog = *pprog;
03f5781be2c7b7 Wang YanQing 2018-05-03 210
03f5781be2c7b7 Wang YanQing 2018-05-03 211 if (dstk) {
03f5781be2c7b7 Wang YanQing 2018-05-03 212 if (val == 0) {
03f5781be2c7b7 Wang YanQing 2018-05-03 213 /* xor eax,eax */
03f5781be2c7b7 Wang YanQing 2018-05-03 @214 EMIT2(0x33, add_2reg(0xC0, IA32_EAX, IA32_EAX));
03f5781be2c7b7 Wang YanQing 2018-05-03 215 /* mov dword ptr [ebp+off],eax */
03f5781be2c7b7 Wang YanQing 2018-05-03 216 EMIT3(0x89, add_2reg(0x40, IA32_EBP, IA32_EAX),
03f5781be2c7b7 Wang YanQing 2018-05-03 217 STACK_VAR(dst));
03f5781be2c7b7 Wang YanQing 2018-05-03 218 } else {
03f5781be2c7b7 Wang YanQing 2018-05-03 219 EMIT3_off32(0xC7, add_1reg(0x40, IA32_EBP),
03f5781be2c7b7 Wang YanQing 2018-05-03 220 STACK_VAR(dst), val);
03f5781be2c7b7 Wang YanQing 2018-05-03 221 }
03f5781be2c7b7 Wang YanQing 2018-05-03 222 } else {
03f5781be2c7b7 Wang YanQing 2018-05-03 223 if (val == 0)
03f5781be2c7b7 Wang YanQing 2018-05-03 224 EMIT2(0x33, add_2reg(0xC0, dst, dst));
03f5781be2c7b7 Wang YanQing 2018-05-03 225 else
03f5781be2c7b7 Wang YanQing 2018-05-03 226 EMIT2_off32(0xC7, add_1reg(0xC0, dst),
03f5781be2c7b7 Wang YanQing 2018-05-03 227 val);
03f5781be2c7b7 Wang YanQing 2018-05-03 228 }
03f5781be2c7b7 Wang YanQing 2018-05-03 229 *pprog = prog;
03f5781be2c7b7 Wang YanQing 2018-05-03 230 }
03f5781be2c7b7 Wang YanQing 2018-05-03 231

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki