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

Peter Rong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 12 15:36:01 PST 2022


Peter created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Peter requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139890

Files:
  llvm/lib/FuzzMutate/IRMutator.cpp


Index: llvm/lib/FuzzMutate/IRMutator.cpp
===================================================================
--- llvm/lib/FuzzMutate/IRMutator.cpp
+++ llvm/lib/FuzzMutate/IRMutator.cpp
@@ -224,10 +224,10 @@
   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 @@
   // 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:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139890.482297.patch
Type: text/x-patch
Size: 1297 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221212/89d2a6ec/attachment.bin>


More information about the llvm-commits mailing list