Patch to clean up MSVC analysis warnings (bug 551690, r=edwsmith+ nnethercote+)

(pushing for Bill Maddox)
The following appear to be false positives.  The patch adjusts the code in a
meaning-preserving way such that the analysis warnings no longer appear.  My
best guess is that the analysis does not take into account the discretenes of
integer arithmetic in analyzing relational operators.

nanojit/Assembler.cpp(2004)
nanojit/Nativei386.cpp(1214)

Here, an outer definition is indeed hidden, but it is dead at this point, and
the code is correct as it stands.  Stylistically, however, the hiding should be
avoided, as in the patch.

nanojit\LIR.cpp(671)

--HG--
extra : convert_revision : fdff643a3c793c57150d0e8b48bc1f12383d939e
This commit is contained in:
Edwin Smith 2010-04-05 11:25:55 -04:00
parent 2fab74a615
commit e802b90f31
3 changed files with 12 additions and 9 deletions

View File

@ -2035,11 +2035,11 @@ namespace nanojit
return i;
}
}
uint32_t const spaceLeft = NJ_MAX_STACK_ENTRY - _highWaterMark - 1;
if (spaceLeft >= 1)
if (_highWaterMark < NJ_MAX_STACK_ENTRY - 1)
{
NanoAssert(_entries[_highWaterMark+1] == BAD_ENTRY);
_entries[++_highWaterMark] = ins;
_highWaterMark++;
_entries[_highWaterMark] = ins;
return _highWaterMark;
}
}

View File

@ -734,7 +734,6 @@ namespace nanojit
}
else if (oprnd1->isconst() && !oprnd2->isconst())
{
LIns* t;
switch (v) {
case LIR_add:
case LIR_mul:
@ -743,12 +742,13 @@ namespace nanojit
case LIR_xor:
case LIR_or:
case LIR_and:
case LIR_eq:
case LIR_eq: {
// move const to rhs
t = oprnd2;
LIns* t = oprnd2;
oprnd2 = oprnd1;
oprnd1 = t;
break;
}
default:
if (isICmpOpcode(v)) {
// move const to rhs, swap the operator

View File

@ -1230,18 +1230,21 @@ namespace nanojit
// ordinary param
AbiKind abi = _thisfrag->lirbuf->abi;
uint32_t abi_regcount = max_abi_regs[abi];
// argRegs must have as many elements as the largest argument register
// requirement of an abi. Currently, this is 2, for ABI_FASTCALL. See
// the definition of max_abi_regs earlier in this file. The following
// assertion reflects this invariant:
NanoAssert(abi_regcount <= sizeof(argRegs)/sizeof(argRegs[0]));
if (arg < abi_regcount) {
// Incoming arg in register.
prepareResultReg(ins, rmask(argRegs[arg]));
// No code to generate.
} else {
// Incoming arg is on stack, and EBP points nearby (see genPrologue()).
Register r = prepareResultReg(ins, GpRegs);
int d = (arg - abi_regcount) * sizeof(intptr_t) + 8;
LD(r, d, FP);
}
} else {
// Saved param.
prepareResultReg(ins, rmask(savedRegs[arg]));