[PATCH] D85639: [Attributor] Fix bug in operator of PotentialValuesState

Shinji Okumura via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 04:55:50 PDT 2020


okura created this revision.
Herald added a reviewer: uenoku.
Herald added subscribers: llvm-commits, kuter, uenoku.
Herald added a reviewer: homerdin.
Herald added a project: LLVM.
okura requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: sstefan1.
Herald added a reviewer: baziotis.
Herald added a subscriber: bbn.

There are bugs in `operator &=` and `operator ^=` in `PotentialValuesState`.
When we clamp states, helper BooleanStates should be but were not clamped.


https://reviews.llvm.org/D85639

Files:
  llvm/include/llvm/Transforms/IPO/Attributor.h


Index: llvm/include/llvm/Transforms/IPO/Attributor.h
===================================================================
--- llvm/include/llvm/Transforms/IPO/Attributor.h
+++ llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -3427,15 +3427,20 @@
 
   /// "Clamp" this state with \p PVS.
   PotentialValuesState operator^=(const PotentialValuesState &PVS) {
+    IsValidState ^= PVS.IsValidState;
     unionAssumed(PVS);
     return *this;
   }
 
   PotentialValuesState operator&=(const PotentialValuesState &PVS) {
+    IsValidState &= PVS.IsValidState;
     unionAssumed(PVS);
     return *this;
   }
 
+  /// A helper state which indicate whether this state is valid or not.
+  BooleanState IsValidState;
+
 private:
   /// Check the size of this set, and invalidate when the size is no
   /// less than \p MaxPotentialValues threshold.
@@ -3485,9 +3490,6 @@
     Set = IntersectSet;
   }
 
-  /// A helper state which indicate whether this state is valid or not.
-  BooleanState IsValidState;
-
   /// Container for potential values
   SetTy Set;
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85639.284315.patch
Type: text/x-patch
Size: 1054 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200810/3af70aac/attachment.bin>


More information about the llvm-commits mailing list