[PATCH] D66635: [Attributor] Clamp operator to extend known state

Hideto Ueno via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 23 03:05:27 PDT 2019


uenoku created this revision.
uenoku added reviewers: jdoerfert, sstefan1.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Similar to `^=` operator for IntegerState, this patch introduces a `+=` operator to "clamp" known information.


https://reviews.llvm.org/D66635

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
@@ -932,6 +932,13 @@
     return *this;
   }
 
+  /// "Clamp" this state with \p R. The result is the maximum of the known
+  /// information but not more than what was assumed before.
+  IntegerState operator+=(const IntegerState &R) {
+    takeKnownMaximum(R.Known);
+    return *this;
+  }
+
   /// Make this the minimum, known and assumed, of this state and \p R.
   IntegerState operator&=(const IntegerState &R) {
     Known = std::min(Known, R.Known);
@@ -1437,6 +1444,13 @@
     return *this;
   }
 
+  /// See IntegerState::operator+=
+  DerefState operator+=(const DerefState &R) {
+    DerefBytesState += R.DerefBytesState;
+    GlobalState += R.GlobalState;
+    return *this;
+  }
+
   /// See IntegerState::operator&=
   DerefState operator&=(const DerefState &R) {
     DerefBytesState &= R.DerefBytesState;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66635.216790.patch
Type: text/x-patch
Size: 1044 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190823/947af54a/attachment.bin>


More information about the llvm-commits mailing list