On Fri, 30 Oct 2026 at 13:18, Richard Henderson
<[email protected]> wrote:
>
> Rather than hard-code -1, or compare < 0, use something
> more descriptive.  This also allows more use of TCGReg.
>
> Reviewed-by: Matt Turner <[email protected]>
> Signed-off-by: Richard Henderson <[email protected]>

>  typedef enum {
> +    TCG_REG_NONE = -1,
>      TCG_REG_EAX = 0,
>      TCG_REG_ECX,
>      TCG_REG_EDX,

This has resulted in Coverity producing a set of new complaints
(CID 1689946, 1689949, 1689951, 1689952, 1689953, 1689954,
1689955), because it now assumes that variables of type TCGReg
can be -1, and that therefore code like:

                TCGReg reg = order[i];
                if (tcg_regset_test_reg(set, reg)) {
(from tcg_reg_alloc_pair(), but the others are similar)

might be buggy, because it hands a TCGReg to tcg_regset_test_reg(),
which uses it as a shift count without checking for the -1
possibility (which would be UB if it happened).

Should we just mark all these as false-positives, or is it
worth maybe having operations that work on a TCGReg but
don't expect TCG_REG_NONE add assertions against that ?

thanks
-- PMM

Reply via email to