Adjusting some guard analysis

This commit is contained in:
caheckman 2020-02-19 13:41:05 -05:00
parent ed786460ca
commit 163fa4af57
4 changed files with 15 additions and 4 deletions

View file

@ -25,8 +25,8 @@
vector<ArchitectureCapability *> ArchitectureCapability::thelist;
const uint4 ArchitectureCapability::majorversion = 3;
const uint4 ArchitectureCapability::minorversion = 5;
const uint4 ArchitectureCapability::majorversion = 4;
const uint4 ArchitectureCapability::minorversion = 0;
/// This builds a list of just the ArchitectureCapability extensions
void ArchitectureCapability::initialize(void)

View file

@ -1033,6 +1033,15 @@ void JumpBasic::analyzeGuards(BlockBasic *bl,int4 pathout)
PcodeOp *cbranch = prevbl->lastOp();
if ((cbranch==(PcodeOp *)0)||(cbranch->code() != CPUI_CBRANCH))
break;
if (i != 0) {
// Check that this CBRANCH isn't protecting some other switch
BlockBasic *otherbl = (BlockBasic *)prevbl->getOut(1-indpath);
PcodeOp *otherop = otherbl->lastOp();
if (otherop != (PcodeOp *)0 && otherop->code() == CPUI_BRANCHIND) {
if (otherop != jumptable->getIndirectOp())
break;
}
}
bool toswitchval = (indpath == 1);
if (cbranch->isBooleanFlip())
toswitchval = !toswitchval;

View file

@ -1066,8 +1066,9 @@ Varnode *CircleRange::pullBack(PcodeOp *op,Varnode **constMarkup,bool usenzmask)
CircleRange nzrange;
if (!nzrange.setNZMask(res->getNZMask(),res->getSize()))
return res;
if (0!=intersect(nzrange))
return (Varnode *)0;
intersect(nzrange);
// If the intersect does not succeed (i.e. produces 2 pieces) the original range is
// preserved and we still consider this pullback successful.
}
return res;
}

View file

@ -2487,6 +2487,7 @@ int4 RuleZextEliminate::applyOp(PcodeOp *op,Funcdata &data)
if (!vn2->isConstant()) return 0;
zext = vn1->getDef();
if (!zext->getIn(0)->isHeritageKnown()) return 0;
if (vn1->loneDescend() != op) return 0; // Make sure extension is not used for anything else
smallsize = zext->getIn(0)->getSize();
val = vn2->getOffset();
if ((val>>(8*smallsize))==0) { // Is zero extension unnecessary