mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-11 09:41:35 +00:00
use atomic read-modify-write increment for LLVM CLASSIC
This commit is contained in:
parent
70bf4b4ab0
commit
00e54565ef
@ -388,7 +388,6 @@ bool AFLCoverage::runOnModule(Module &M) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// other constants we need
|
// other constants we need
|
||||||
ConstantInt *Zero = ConstantInt::get(Int8Ty, 0);
|
|
||||||
ConstantInt *One = ConstantInt::get(Int8Ty, 1);
|
ConstantInt *One = ConstantInt::get(Int8Ty, 1);
|
||||||
|
|
||||||
Value * PrevCtx = NULL; // CTX sensitive coverage
|
Value * PrevCtx = NULL; // CTX sensitive coverage
|
||||||
@ -628,6 +627,10 @@ bool AFLCoverage::runOnModule(Module &M) {
|
|||||||
|
|
||||||
/* Update bitmap */
|
/* Update bitmap */
|
||||||
|
|
||||||
|
#if 1 /* Atomic */
|
||||||
|
IRB.CreateAtomicRMW(llvm::AtomicRMWInst::BinOp::Add, MapPtrIdx, One, llvm::AtomicOrdering::Monotonic);
|
||||||
|
|
||||||
|
#else
|
||||||
LoadInst *Counter = IRB.CreateLoad(MapPtrIdx);
|
LoadInst *Counter = IRB.CreateLoad(MapPtrIdx);
|
||||||
Counter->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
|
Counter->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
|
||||||
|
|
||||||
@ -651,6 +654,7 @@ bool AFLCoverage::runOnModule(Module &M) {
|
|||||||
* Counter + OverflowFlag -> Counter
|
* Counter + OverflowFlag -> Counter
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
ConstantInt *Zero = ConstantInt::get(Int8Ty, 0);
|
||||||
auto cf = IRB.CreateICmpEQ(Incr, Zero);
|
auto cf = IRB.CreateICmpEQ(Incr, Zero);
|
||||||
auto carry = IRB.CreateZExt(cf, Int8Ty);
|
auto carry = IRB.CreateZExt(cf, Int8Ty);
|
||||||
Incr = IRB.CreateAdd(Incr, carry);
|
Incr = IRB.CreateAdd(Incr, carry);
|
||||||
@ -660,6 +664,8 @@ bool AFLCoverage::runOnModule(Module &M) {
|
|||||||
IRB.CreateStore(Incr, MapPtrIdx)
|
IRB.CreateStore(Incr, MapPtrIdx)
|
||||||
->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
|
->setMetadata(M.getMDKindID("nosanitize"), MDNode::get(C, None));
|
||||||
|
|
||||||
|
#endif /* non atomic case */
|
||||||
|
|
||||||
/* Update prev_loc history vector (by placing cur_loc at the head of the
|
/* Update prev_loc history vector (by placing cur_loc at the head of the
|
||||||
vector and shuffle the other elements back by one) */
|
vector and shuffle the other elements back by one) */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user