[llvm] 2328c0e - [FuzzMutate] InstModStrategy: switch nsw/nuw/inbount instead of repeated setting it

Peter Rong via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 13 20:50:06 PST 2022


Author: Peter Rong
Date: 2022-12-13T20:50:00-08:00
New Revision: 2328c0e071f5fe34bbcfa99ab3abdb3f4fc76d82

URL: https://github.com/llvm/llvm-project/commit/2328c0e071f5fe34bbcfa99ab3abdb3f4fc76d82
DIFF: https://github.com/llvm/llvm-project/commit/2328c0e071f5fe34bbcfa99ab3abdb3f4fc76d82.diff

LOG: [FuzzMutate] InstModStrategy: switch nsw/nuw/inbount instead of repeated setting it

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D139890

Added: 
    

Modified: 
    llvm/lib/FuzzMutate/IRMutator.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/FuzzMutate/IRMutator.cpp b/llvm/lib/FuzzMutate/IRMutator.cpp
index 6c0c2ddc0d6c1..a588bc8c15f51 100644
--- a/llvm/lib/FuzzMutate/IRMutator.cpp
+++ b/llvm/lib/FuzzMutate/IRMutator.cpp
@@ -224,10 +224,10 @@ void InstModificationIRStrategy::mutate(Instruction &Inst,
   case Instruction::Mul:
   case Instruction::Sub:
   case Instruction::Shl:
-    Modifications.push_back([&Inst]() { Inst.setHasNoSignedWrap(true); });
-    Modifications.push_back([&Inst]() { Inst.setHasNoSignedWrap(false); });
-    Modifications.push_back([&Inst]() { Inst.setHasNoUnsignedWrap(true); });
-    Modifications.push_back([&Inst]() { Inst.setHasNoUnsignedWrap(false); });
+    Modifications.push_back(
+        [&Inst]() { Inst.setHasNoSignedWrap(!Inst.hasNoSignedWrap()); });
+    Modifications.push_back(
+        [&Inst]() { Inst.setHasNoUnsignedWrap(!Inst.hasNoUnsignedWrap()); });
     break;
   case Instruction::ICmp:
     CI = cast<ICmpInst>(&Inst);
@@ -240,8 +240,8 @@ void InstModificationIRStrategy::mutate(Instruction &Inst,
   // Add inbound flag.
   case Instruction::GetElementPtr:
     GEP = cast<GetElementPtrInst>(&Inst);
-    Modifications.push_back([GEP]() { GEP->setIsInBounds(true); });
-    Modifications.push_back([GEP]() { GEP->setIsInBounds(false); });
+    Modifications.push_back(
+        [GEP]() { GEP->setIsInBounds(!GEP->isInBounds()); });
     break;
   // Add exact flag.
   case Instruction::UDiv:


        


More information about the llvm-commits mailing list