[llvm] [Attributor] Fix an issue that could potentially cause `AccessList` and `OffsetBins` out of sync (PR #106187)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 26 22:37:02 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Shilei Tian (shiltian)

<details>
<summary>Changes</summary>

The implementation of `AAPointerInfo::RangeList::set_difference` doesn't
consider the case where two ranges have the same offset but different sizes.
This could causes `AccessList` and `OffsetBins` out of sync because a range has
been already updated in `AccessList` but missing in `ToRemove`.

I do have a reproducer but the reproducer itself is 248kb. `llvm-reduce` can't
further reduce it. Not sure how I can make a smaller reproducer.

Fix SWDEV-479757.

---
Full diff: https://github.com/llvm/llvm-project/pull/106187.diff


1 Files Affected:

- (modified) llvm/include/llvm/Transforms/IPO/Attributor.h (+4-1) 


``````````diff
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index 718cf704cbdf1a..e4e94ad40acb8d 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -5818,7 +5818,10 @@ struct AAPointerInfo : public AbstractAttribute {
     static void set_difference(const RangeList &L, const RangeList &R,
                                RangeList &D) {
       std::set_difference(L.begin(), L.end(), R.begin(), R.end(),
-                          std::back_inserter(D), RangeTy::OffsetLessThan);
+                          std::back_inserter(D),
+                          [](const RangeTy &L, const RangeTy &R) {
+                            return (L.Offset < R.Offset) || (L != R);
+                          });
     }
 
     unsigned size() const { return Ranges.size(); }

``````````

</details>


https://github.com/llvm/llvm-project/pull/106187


More information about the llvm-commits mailing list