mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-12 18:18:07 +00:00
do not instrument icmp/fcmp if result is used in select
This commit is contained in:
@ -821,13 +821,16 @@ bool ModuleSanitizerCoverageAFL::InjectCoverage(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool instrumentInst = false;
|
bool instrumentInst = false;
|
||||||
|
ICmpInst *icmp;
|
||||||
|
FCmpInst *fcmp;
|
||||||
|
|
||||||
if (isa<FCmpInst>(&IN) || isa<ICmpInst>(&IN) || isa<SelectInst>(&IN)) {
|
if ((icmp = dyn_cast<ICmpInst>(&IN)) ||
|
||||||
|
(fcmp = dyn_cast<FCmpInst>(&IN)) || isa<SelectInst>(&IN)) {
|
||||||
|
|
||||||
// || isa<PHINode>(&IN)
|
// || isa<PHINode>(&IN)
|
||||||
|
|
||||||
bool usedInBranch = false;
|
bool usedInBranch = false, usedInSelectDecision = false;
|
||||||
|
|
||||||
for (auto *U : IN.users()) {
|
for (auto *U : IN.users()) {
|
||||||
|
|
||||||
@ -838,9 +841,23 @@ bool ModuleSanitizerCoverageAFL::InjectCoverage(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auto *sel = dyn_cast<SelectInst>(U)) {
|
||||||
|
|
||||||
|
if (icmp && sel->getCondition() == icmp) {
|
||||||
|
|
||||||
|
usedInSelectDecision = true;
|
||||||
|
|
||||||
|
} else if (fcmp && sel->getCondition() == fcmp) {
|
||||||
|
|
||||||
|
usedInSelectDecision = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!usedInBranch) {
|
if (!usedInBranch && !usedInSelectDecision) {
|
||||||
|
|
||||||
// errs() << "Instrument! " << *(&IN) << "\n";
|
// errs() << "Instrument! " << *(&IN) << "\n";
|
||||||
instrumentInst = true;
|
instrumentInst = true;
|
||||||
@ -1004,13 +1021,16 @@ bool ModuleSanitizerCoverageAFL::InjectCoverage(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool instrumentInst = false;
|
bool instrumentInst = false;
|
||||||
|
ICmpInst *icmp;
|
||||||
|
FCmpInst *fcmp;
|
||||||
|
|
||||||
if (isa<FCmpInst>(&IN) || isa<ICmpInst>(&IN) || isa<SelectInst>(&IN)) {
|
if ((icmp = dyn_cast<ICmpInst>(&IN)) ||
|
||||||
|
(fcmp = dyn_cast<FCmpInst>(&IN)) || isa<SelectInst>(&IN)) {
|
||||||
|
|
||||||
// || isa<PHINode>(&IN)
|
// || isa<PHINode>(&IN)
|
||||||
|
|
||||||
bool usedInBranch = false;
|
bool usedInBranch = false, usedInSelectDecision = false;
|
||||||
|
|
||||||
for (auto *U : IN.users()) {
|
for (auto *U : IN.users()) {
|
||||||
|
|
||||||
@ -1021,9 +1041,23 @@ bool ModuleSanitizerCoverageAFL::InjectCoverage(
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auto *sel = dyn_cast<SelectInst>(U)) {
|
||||||
|
|
||||||
|
if (icmp && sel->getCondition() == icmp) {
|
||||||
|
|
||||||
|
usedInSelectDecision = true;
|
||||||
|
|
||||||
|
} else if (fcmp && sel->getCondition() == fcmp) {
|
||||||
|
|
||||||
|
usedInSelectDecision = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!usedInBranch) {
|
if (!usedInBranch && !usedInSelectDecision) {
|
||||||
|
|
||||||
// errs() << "Instrument! " << *(&IN) << "\n";
|
// errs() << "Instrument! " << *(&IN) << "\n";
|
||||||
instrumentInst = true;
|
instrumentInst = true;
|
||||||
@ -1037,8 +1071,6 @@ bool ModuleSanitizerCoverageAFL::InjectCoverage(
|
|||||||
Value *result = nullptr;
|
Value *result = nullptr;
|
||||||
uint32_t vector_cnt = 0;
|
uint32_t vector_cnt = 0;
|
||||||
SelectInst *selectInst;
|
SelectInst *selectInst;
|
||||||
ICmpInst *icmp;
|
|
||||||
FCmpInst *fcmp;
|
|
||||||
// PHINode *phi = nullptr, *newPhi = nullptr;
|
// PHINode *phi = nullptr, *newPhi = nullptr;
|
||||||
IRBuilder<> IRB(IN.getNextNode());
|
IRBuilder<> IRB(IN.getNextNode());
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user